File Type Mode Size
.cargo/ dir 0 0
.gitignore file 644 63
Cargo.toml file 644 907
README.md file 755 2466
build-external.sh file 755 1219
build.rs file 644 1073
crt/ dir 0 0
external/ dir 0 0
fetch-external.sh file 755 319
memory.x file 644 2441
shell/ dir 0 0
src/ dir 0 0
README.md

hello-m

A simple microcontroller hacking environment

Building

Not gonna lie, this is a terrible mess right now.

Install a copy of the GNU Arm Embedded Toolchain and put it in your path. You can get gcc-arm-none-eabi on debian-style systems, but I recommend getting a newer version.

Run ./fetch-external.sh. That should retrieve the external dependencies and patch them.

Run ./build-external.sh. This should produce libc.a, libm.a, and liblua.a in libs/.

Cd to shell and run make. This will produce libshell.a.

Finally, run cargo build. If you want NTSC video, that currently only works in release mode with --release.

Using

Flash to your Due and connect to the serial port (the programming port, not the native port). You should get a Lua shell.

peek and poke

Two utility functions are provided, peek(addr) and poke(addr, val), which will read or write 32-bit memory values.

memory map

The Due's 96KB is split into a 64KB user segment, and a 32KB kernel segment. The user segment is empty and can be fully utilized by application software. The kernel segment is further divided into a public and private portion. The public portion is accessible to user programs and contains data supporting application services like the memory allocator state, and publicly accessible service state like video RAM. The private portion contains management data for system services and the main stack for exception handling.

In user mode, the MPU pokes out several holes in the address space.

0x00000000  +------------------+
            |       ROM        |
0x00080000  +------------------+
                    ...
0x20000000  +------------------+
            |     User RAM     |
0x20010000  +------------------+
                    ...
0x2001F000  +------------------+
            |    User Stack    | (mirrored User RAM)
0x20020000  +------------------+
                    ...
0x20080000  +------------------+
            |  Public Kernel   |
0x20084000  +------------------+
            |  Private Kernel  |
0x20088000  +------------------+
                    ...
0x40000000  +------------------+
            |   Peripherals    |
0x60000000  +------------------+

There's of course a lot more to the memory map, and I recommend perusing the ATSAM3X/A datasheet for more information.

Clone: https://git.bytex64.net/hello-m.git