Moore’s Law marches on, and more and more circuits are crowded into microcontrollers. In the last 15 years, I had programmed many ARM chips, and had watched with amazement the progress of the ARM chips. My approach had always been to port an eForth system onto the chips and tried to make the best use of the chips. Here are some of the ARM chips I put eForth on.
2001: Nintendo’s GameBoyAdvance had an ARM7TDMI chip in it. It had 32 KB of RAM. No flash. It had lots of external flash and RAM for games.
2004: ADuC7024 from Analog Devices had 62 KB of flash and 8 KB of RAM, and lots of IO devices, including ADC and DAC. I built a ForthStamp based on it, a really nice single chip stamp size computer.
2008: AT91SAM7x256 from Atmel. It had 64 KB of flash and 16 KB of RAM, and lots of IO devices.
A couple of years ago, I told my friends in the Silicon Valley FIG and Taiwan FIG that I had to really retire from Forth programming. I did, and worked peacefully on translating Bach’s cantatas from German to Chinese, and putting Tang poems into Schubert’s songs, and many other things I had neglected all the years. Then, last month, a friend in Taiwan FIG sent me this ForthDuino Board, which was used to control a laser cutting machine to make PC boards. It had footprints of IO sockets of Arduino board and MSP430 LaunchPad. It is intended to suck in all applications from Arduino and
LaunchPad. I was told that the ARM chip on ForthDuino is the same one used in the STM32F4Discovery Kit. Looking up the STM32F407 chip, I was shocked to see so much memory, and so many IO devices. 1 MB of flash and 192 KB of RAM. It is a Wow chip, and in desperate need of a good eForth system.
So. I re-open my workbench, unpacked my tools, download all necessary IDE and programming toolchains. But, the world has changed since I stopped watching. Keil is still there, but its toolchain became uVision5. STM32F4 is no longer an ARM chip. It is a Cortex M4 chip. There is no ARM in STM32F4. All that’s left is a THUMB, and a really big THUMB.
The first shock was that I could not use the ARM directive in the assembler. The assembler generated lots of error messages if you do ARM. It is much happier if you use the THUMB directive. Then, the RSC instruction disappeared. Reading the ARM assembler manual carefully, I found that ARM.
Holdings is phasing out the ARM instruction set, and replacing it with the THUMB2 instruction set. It gave up the beautiful RISC architecture, and reverted to the ugly CISC architecture we all despised.
I missed the simple serial COM port in PC. The USB is so much harder to deal with. You don’t know what’s going on. You must have faith on the USB drivers given to you.
There is no simple example to guide me, to start my exploration. The Demo project provided with STAM32F4-Discovery Kit is a huge package with 7 folders and 31 files. There is no clear entry point. I spent 3 weeks wandering around in the hardware and software maze, looking for an entry point. The great breakthrough came when I realized that I only had to set up the reset vector correctly, everything would work smoothly from that point on. Throw away all the header files, init files, device driver files. I only need one assembly file to do what I have to do.
Since STM32F4 is no longer an ARM7 chip. It is not necessary to keep the name in my eForth implementations. I planned and completed 3 versions of eForth for this chip:
STM32eforth v7.01 The eForth dictionary resides in flash memory, and executes from flash memory. It is upgraded to align with the eForth2 model, with subroutine tread model and fully optimized for performance.
STM32eforth v7.10 The eForth dictionary resides in flash memory. Flash memory is remapped to the virtual memory in Page 0. eForth executes from Page 0 memory.