I have been working with Netduino Mini, Netduino 1 and Netduino Plus.. so I thought I'd try doing some Cortex-M3 "bare metal" programming on the Netduino 2 (N2).
I power-up the N2 with the pushbutton pushed, so the "STM32F2BOOTLOADER" gets invoked (and I'm able to upload/download files to flash with the STM DfuSe tool). So far so good.
The GNU ARM toolchain I was using didn't support "-mcpu=cortex-m3 -mthumb." So I grabbed the latest and greatest YAGARTO release. Now things seem to build okay.
The binary file I download to flash (08000000) basically looks like:
0: 2000 e000
4: 0800 0021
20: <my program>
"My Program" basically does (all I'm trying to do is to print a character to the serial port (USART2)):
Enable USART2 in RCC_APB1ENR
Enable PIOA in RCC_AHB1ENR
for the USART2_TX pin (PIOA pin 2 Alternate Function 7)..
GPIOA_MODE(pin 2) = GPIO_MODE_AF
GPIOA_OSPEED(pin 2) = GPIO_SPEED_50MHz
GPIOA_OTYPE(pin 2) = GPIO_OTYPE_PUSHPULL
GPIOA_PUPDR(pin 2) = GPIO_PUPDR_NOPULL
GPIOA_AFRL(pin 2) = 7
the I setup the USART (USART2)
I set it up for 8-bits, no parity, 1 stop bit, no hardware flow control, and 38400 baud (which translates to DIV_Mantissa = 0x30 and DIV_Fraction = 0xd). I enable the transmitter (CR1.TE) and receiver (CR1.RE).. then enable the USART itself (CR1.UE).
Then I just go into a loop, outputting a character as soon as the USART STATUS.TXE goes to 1.
I have one specific question, and one general one:
(1) When I look at the "Reset Sequence" in "The Definitive Guide to the ARM Cortex-M3" (pp. 44-46), it says that the reset vector should have its LSB set to 1 (for thumb). Sounds reasonable, but I've seen many other reset examples that don't mention that at all. Is "The Definative Guide" right on this?
(2) I know it's just pseudo-code, but does anything strike anyone as a glaring omission and/or mistake?
Thanks,
Tom