-
Notifications
You must be signed in to change notification settings - Fork 11
Changes Required to the CSSE3010 Code
Here is a list of the changes that need to be made to the code/Makefiles before the code can run on QEMU. This is for Non-FreeRTOS code.
An example git patch can be seen at: https://github.com/alistair23/CSSE3010-QEMU-Examples/blob/master/project1.patch
The Makefile for each compile needs to be updated. An example update is shown below:
diff --git a/Makefile b/Makefile
-CC=arm-none-eabi-gcc
-OBJCOPY=arm-none-eabi-objcopy
+CROSS_COMPILE=arm-none-eabi-
+CC=$(CROSS_COMPILE)gcc
+OBJCOPY=$(CROSS_COMPILE)objcopy
+OBJDUMP=$(CROSS_COMPILE)objdump
-CFLAGS = -g -O1 -Wall -T$(NP2_PATH)/stm32_flash.ld -Wmaybe-uninitialized
-CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -DUSE_STDPERIPH_DRIVER -DUSE_STM324xG_EVAL
-CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
-CFLAGS += -DENABLE_VCP
+CFLAGS = -g -O0 -Wall -T$(NP2_PATH)/stm32_flash.ld -Wmaybe-uninitialized -DNO_FPU
+CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 -mthumb-interwork -DUSE_STDPERIPH_DRIVER -DUSE_STM324xG_EVAL
-LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
+LD_SYS_LIBS = -lm -lc -lgcc -lnosys
The macro #define ENABLE_DEBUG_UART
needs to be added to the top of the Netduinoplus2.h
file.
This changes the DEBUG_SEND_HOOK()
macro that is defined in debug_printf.c
NOTE: When the ENABLE_DEBUG_UART
macro is defined the Netduino Plus 2 can NOT be accessed with Kermit
Depending on how the guest is reading characters some other changes are required
If the VCP_getchar() function is being used, it needs to be changed to work over USART instead of USB.
First remove the original one
diff --git a/main.c b/main.c
/* Private function prototypes -----------------------------------------------*/
-uint8_t VCP_getchar(char* rx);
+//uint8_t VCP_getchar(char* rx);
Then add a new definition
diff --git a/main.c b/main.c
+uint8_t VCP_getchar(char* rx)
+{
+ if (USART_GetFlagStatus(USART6, USART_FLAG_RXNE) == SET) {
+ *rx = USART_ReceiveData(USART6);
+ USART_ClearFlag(USART6, USART_FLAG_RXNE);
+ return 1;
+ }
+ return 0;
+}
Now that USART is being used, it must also be initialised.
Where the other components are initialised (generally inside the Hardware_init() function) add:
diff --git a/main.c b/main.c
void Hardware_init(void) {
+ USART_InitTypeDef USART_debug;
+
NP2_LEDInit();
NP2_LEDOff();
...
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
+
+ USART_debug.USART_BaudRate = 4800; //115200;
+ USART_debug.USART_WordLength = USART_WordLength_8b;
+ USART_debug.USART_StopBits = USART_StopBits_1;
+ USART_debug.USART_Parity = USART_Parity_No;
+ USART_debug.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+ USART_debug.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+
+ USART_Init(USART6, &USART_debug);
+ USART_Cmd(USART6, ENABLE);
Copyright and Written by Alistair Francis