top of page

5 Minute User Space "Hello, World!" ARM Cross Compile, Copy to a RootFS and Run on QEMU

Updated: May 14, 2023



This post shows you how to write a user space Hello, World! program, cross-compile it for ARM, copy into a Root FS and run the new Root FS on QEMU.


Before you Start


Read and follow the ARM instructions listed in 15 Minute Setup to Find, Change, Recompile and Test an ARM or x86 Linux Kernel Change in 12 Seconds at [link]


Steps


Create helloworld.c


1. Type cd ~/tla/linux-4.10.6

2. Type mkdir -p helloworld

3. Type cd helloworld

4. Type vi helloworld.c and enter:


5. Save the file with :w and quit with :q


Compile It


1. Type cd ~/tla/linux-4.10.6

2. Type cd helloworld

3. Type arm-linux-gnueabi-gcc helloworld.c -o helloworld -static

4. Type ls -l

You should see the new exe



Copy helloworld to the Rootfs Staging Area and repack the RootFS


1. Type cd ~/tla/linux-4.10.6

2. Type source ~/envset.sh

3. Type cd helloworld

4. Type cp -av helloworld $TOP/initramfs/arm-busybox

5. Create the initramfs



Boot QEMU and Run helloworld

1. Type

2. After boot type ls /usr/bin check that helloworld is in /usr/bin

You should see:

3. Run helloworld by typing helloworld

You should see:

4. Type Control-a x to quit QEMU



References

bottom of page