#include "lpc43xx.h"
void main() __attribute__ ((naked));
void main() {
LPC_SCU->SFSPE_5 = 4;
LPC_GPIO_PORT->DIR[7] |= (1<<5);
while (1) ;
} |
arm-uclinuxeabi-gcc -O0 -I. -mcpu=cortex-m0 -mthumb -c test.c -o test.o arm-uclinuxeabi-objcopy -O binary test.o test.bin |
00000000 <main>: 0: 4a06 ldr r2, [pc, #24] ; (1c <main+0x1c>) 2: 4b07 ldr r3, [pc, #28] ; (20 <main+0x20>) 4: 2104 movs r1, #4 6: 50d1 str r1, [r2, r3] 8: 4a06 ldr r2, [pc, #24] ; (24 <main+0x24>) a: 4906 ldr r1, [pc, #24] ; (24 <main+0x24>) c: 4b06 ldr r3, [pc, #24] ; (28 <main+0x28>) e: 58c9 ldr r1, [r1, r3] 10: 2320 movs r3, #32 12: 4319 orrs r1, r3 14: 4b04 ldr r3, [pc, #16] ; (28 <main+0x28>) 16: 50d1 str r1, [r2, r3] 18: e7f2 b.n 0 <main> 1a: 46c0 nop ; (mov r8, r8) 1c: 40086000 .word 0x40086000 20: 00000714 .word 0x00000714 24: 400f4000 .word 0x400f4000 28: 0000201c .word 0x0000201c |
uint8_t *region = 0x10080000;
fd = open("test.bin",O_RDONLY);
read(fd,region,64); |
main()
{
// Testing to run code in M0
uint8_t *CM0image_start = (uint8_t *)0x10080000;
RGU_RESET_CTRL1 = (1u << 24); // Put the M0-core in RESET
int fd = open("m0.bin", O_RDONLY);
if (fd)
{
while (read(fd, CM0image_start, 256) > 0) // Read the executable into internal SRAM area
{
;
}
}
unsigned int *pCREG_M0APPMAP = (unsigned int *) 0x40043404;
*pCREG_M0APPMAP = (unsigned int) CM0image_start;
RGU_RESET_CTRL1 = 0x0; // Release the M0 core from RESET
while (1)
{
; // Halt here, and let M0 execute.
}
}
|
#include <stdint.h>
#define GPIO_PORT3_DIR (*((volatile uint32_t *) 0x400f600c)) #define GPIO_PORT3_TOGGLE (*((volatile uint32_t *) 0x400f630c))
void main() __attribute__ ((naked));
void main(void)
{
GPIO_PORT3_DIR |= 0x0100; // Set 8th bit to output
while (1)
{
GPIO_PORT3_TOGGLE = 0x0100; // Toggle bit 8 on GPIO3.
}
}
|
.syntax unified .cpu cortex-m0 .thumb .section resetvector .word 0x10087ff0 /* stack top address */ .word _start /* 1 Reset */ .word _start /* 2 NMI */ .word _start /* 3 HardFault */ .word _start /* 4 MemManage */ .word _start /* 5 BusFault */ .word _start /* 6 UsageFault */ .word _start /* 7 RESERVED */ .word _start /* 8 RESERVED */ .word _start /* 9 RESERVED*/ .word _start /* 10 RESERVED */ .word _start /* 11 SVCall */ .word _start /* 12 Debug Monitor */ .word _start /* 13 RESERVED */ .word _start /* 14 PendSV */ .word _start /* 15 SysTick */ .word _start /* 16 External Interrupt(0) */ .word _start /* 17 External Interrupt(1) */ .word _start /* 18 External Interrupt(2) */ .word _start /* 19 ... */ _start: bl main b hang hang: b . |
SECTIONS
{
. = 0x10080000;
.text : {
startup.o (resetvector)
*(.text*)
}
}
|
int main(void) {
uint32_t i;
LPC_SCU->SFSPE_5 = 4;
LPC_GPIO_PORT->DIR[7] |= (1<<5);
while (1) {
LPC_GPIO_PORT->PIN[7] |= (1<<5);NOPx(10000000);
LPC_GPIO_PORT->PIN[7] &= ~(1<<5);NOPx(10000000);
}
return 0;
}
|