-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathmbed-os-to-arduino
18 lines (15 loc) · 966 Bytes
/
mbed-os-to-arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export BOARDNAME=DISCO_F429ZI
export ARDUINOCORE=~/ArduinoCore-mbed/cores/arduino/mbed/
mbed new mbed-os-program
cd mbed-os-program
mbed target $BOARDNAME
mbed toolchain GCC_ARM
echo "int main(int argc, char** argv) {}" > main.c
mbed compile -v | grep "Macros:" > $BOARDNAME.macros.txt
arm-none-eabi-ar rcs BUILD/mbed-core-$BOARDNAME.a `xargs -n 1 < ./BUILD/$BOARDNAME/GCC_ARM/.link_options.txt | grep "\.o" | grep -v "main.o"`
cp mbed-os/mbed.h $ARDUINOCORE
cd mbed-os && cat mbed.h | grep "\.h" | cut -f2 -d "\"" | xargs -I % cp --parents % $ARDUINOCORE
# find a way to extract PinNames.h and device.h
# patch Callback.h
# copy linker script (eg. BUILD/DISCO_F429ZI/GCC_ARM/.link_script.ld)
openocd -f interface/stlink-v2.cfg -f target/stm32f4x_stlink.cfg -c "init" -c "reset init" -c "halt" -c "flash write_image erase ./BUILD/$BOARDNAME/GCC_ARM/mbed-os-program.elf" -c "verify_image ./BUILD/$BOARDNAME/GCC_ARM/mbed-os-program.elf" -c "reset run" -c shutdown