Friday, December 25, 2009

Checked hw-working code into SVN...

Finally cracked serial port and clock setup on real hardware tonight. I was also able to set up the PLL to run the chip at 50mhz - and even over clock it to 100mhz. :)

Interrupts don't work yet, but eh.

I think I should write something FORTH-like next so I won't have to flash the chip too much, or at least a super-simple interpreter of some sort for HW bringup.

Tuesday, December 15, 2009

c++ virtual-functioning runtime in 270 lines, no asm.

Interrupts definitely won't work yet, but I've got virtual functions working and it's dealing with multiple source files even. No assembly needed! (and it does use libgcc for some helper code...)

Saturday, December 12, 2009

Cortex-M3 + CodeSourcery startup...

This .pdf documents how to write a minimal C program to run on the LM3S811EVB qemu target:

Install CodeSourcery and have fun! I'm going to look into elaborating on this over the weekend. Maybe even blink an LED on my LPC13xx board...


Compiling CMSIS w/CodeSourcery w/o IDE...

This is for the LPC13XX target. This also works with Luminary Micro's stuff as long as you change the relevant LPC13xx's to LM3's.

- Get the CodeSourcery tarball for Linux and extract it.
- Set path to [extraction dir]/bin:$PATH to get the toolchain in path

- Get the CMSIS library from and extract it
- create a flat cmsis directory outside of that tree
- copy CMSIS_V1P30/CM3/CoreSupport/core_cm3.* to it
- then CMSIS_V1P30/CM3/DeviceSupport/NXP/LPC13xx/startup/gcc/*
- finally CMSIS_V1P30/CM3/Example/Sourcery\ G++Lite/LPC13xx/*

Then make a start.c with an empty _start() function.

To build: arm-none-eabi-gcc -mcpu=cortex-m3 -msoft-float -mthumb -fno-common -Wl,-cref,'-Map=map.txt',-S,'-TLPC13xx.ld' *.c startup_LPC13xx.s

And to de-ELF it so you can write it to flash: arm-none-eabi-objcopy a.out -O binary a.bin

Now to actually build and run code. The next step is to build the LM3 version and run it under qemu's L3MS811 EVB emulation... and not have it crash.

Thursday, December 10, 2009

Some crazy macro-abuse I came up with..

... not terribly useful in and of itself, but it allows for an organized extensible systemcall-y/pseudo-dynamic library setup.

#include <stdio.h>

#define BEGIN_FUNC(name, inm, outm) \
typedef struct name##_in_t { inm } name##_in; \
typedef struct name##_out_t { outm } name##_out; \
name##_out name(name##_in *in) {name##_out out; printf("l%d %d\n", sizeof(name##_in), sizeof(name##_out));

#define END_FUNC return out;}
#define CALL(output, name, invar ... ) output = name(&(name##_in){invar})
#define CALLA(output, name, invar ... ) name##_out output = name(&(name##_in){invar})

BEGIN_FUNC(test, int a; int ab;, int b;)
printf("%d %d\n", in->a, in->ab);
out.b = in->a * 2;

int main(void)
int x = 2;

CALLA(outpt, test, 20, x);
printf("%d\n", outpt.b);
CALL(outpt, test, 30);
printf("%d\n", outpt.b);

return 0;