In a similar vein to the 1$/1M and ghetto ARM threads, here's my work-in-progress attempt at minimal C development on NXP's LPC Cortex M series.
What are you doing, and why?This is part learning opportunity, and part practical project. My "dev board" is a prototype 8-port remote serial console box, intended to provide access via Ethernet, USB, or local DB-9 RS-232, to (up to) 8 serial devices, such as a managed network device like a router or switch. I come from a telecom background, and this is usually the kind of job where one would use an older Cisco router with an async serial card, or a dedicated serial concentrator appliance. Both options are easily >$1,000 devices, and I figure I could build something cheaper that is "good enough" nearly all of the time.
However, all that is purely to illustrate my motivation for learning ARM -- the hardware is not particularly relevant to this discussion. The point of this thread is to document the process of learning how to build an ARM Cortex M device of your own. This can be as simple as a breakout board exposing only power, reset, UART0, and the ISP_Enable pin; or it can be some pet project like mine. As long as you have TTL serial access to an LPC with a boot ROM providing ISP-over-UART support, it's all good.
About the hardwareI'm tackling a complicated PCB design as well, which is probably not a great way to begin, but I'm stubborn like that. Hopefully, my errors can serve as a useful lesson in basic hardware implementation as well. Someone asked for reference designs recently, which are relatively difficult to find (compared to, say, AVR.) I'll publish relevant parts of my design (don't want to muddy the waters with extraneous detail), where hopefully anyone more experienced can point out potential problems along the way. Anything I publish here is free to use however you want. Use it as a reference, copy it verbatim, whatever.
OK... In my case, the dev board's main CPU is an LPC4078 -- a Cortex M4F (it actually has a second M0 core, but nevermind that for now.) It will also have one LPC812 (Cortex M0+) per downstream serial port (they ended up being cheaper than dedicated UART ICs, and allow programmable TX/RX LED control for free), so there's a bonus goal of having the main CPU flash the secondary CPUs as well. The datasheets for these two parts (well, part families actually) seem to have 100% compatible boot ROM implementations, so I'm hoping that's the case across the product line, but I don't make any guarantees. The 812 looks like a neat little chip on paper, and it's inexpensive, so if you're wondering where to begin, that would be as good a place to start as any. (NOTE: It does not have an onboard ADC, if that matters to you.)
As for the software...The only assumption is that the code will compile with GCC. I would prefer the code to be as cross-platform as possible, and so I also have IAR Embedded Workbench installed for compatibility testing. My preferred coding environment is Kate (KDE's multi-document, syntax-highlighting, general-purpose editor), Make, and GCC. Anyone should be able to follow along with their choice of editor, and the GNU toolchain. I'll provide info on how to set all that stuff up when I figure out for myself.
(In the past, I have leaned on Gentoo's automated cross-compiling framework to compile for non-native architectures, but I would like to learn more about how to set up a build environment that isn't tied to a specific distro.)
What's next?Step one is to establish communications from a PC to the LPC's boot ROM using a standard FTDI TTL serial cable. There are existing tools to upload HEX images, but I said "from scratch" and I mean it, so I'm brewing a DIY implementation that should compile and run in any POSIX-compliant environment. This is where things get complicated for Windows users, as it's not particularly well suited to POSIX applications... If I can, I'll try to write a Windows console application port as well. In theory, OS X should be able to use the POSIX version. I'll try to verify this.
It's up to you to provide a the TTL serial interface. I use a standard FTDI USB-to-TTL cable. It has a 5-pin 0.1" female header on the end with Gnd, +5v (USB Vbus), and 5v-tolerant 3.3v signalling lines for TX, RX, CTS, and RTS. AVR fans should be familiar with how avrdude uses RTS to reset the MCU. I'm going to try to duplicate this behavior. Take it or leave it. My software will happily wait for you to manually reset the MCU if you prefer.
OK, but why?None of this is a practical, low-effort, time-to-market driven approach. It's 100% wheel-reinventing, for the purpose of learning how to make your own wheel. A typical complaint from ARM newbies is "where do I start?" This guide comes from a fellow ARM newbie wondering where to start. I don't know, so I'm figuring it out, and sharing what I learn along the way. I'll make mistakes, and I'll do things in an unnecessarily difficult and time-consuming way. At least I hope so. Be patient and point it out if you see me leading others astray. Once I have a more or less workable solution, I'll condense the material and post it on the web.
Alright, here we go.
EDIT: I'll try to keep a section here up-to-date with links to pertinent topics and files.
Boot ROM Serial Flash Code: revision 11 (Thu., Oct. 14, 2014)