Skip to content

Instantly share code, notes, and snippets.

@av1024
Last active December 29, 2017 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save av1024/b6df7ba5f7ce6aa9011445ba8d5e1b86 to your computer and use it in GitHub Desktop.
Save av1024/b6df7ba5f7ce6aa9011445ba8d5e1b86 to your computer and use it in GitHub Desktop.
rtlDuino (RTL87xx dev) Arduino@linux upload (JLinkRAM/IMG network OTA tested)
#!/bin/bash
if [ ! -d "${1}" ]; then
# goto no_dir
JLinkGDBServer -device Cortex-M3 -if SWD -ir -endian little -speed 3500 &
arm-none-eabi-gdb -x gdb_img.jlink
killall JLinkGDBServer
exit 0
fi
if [ ! -f "${1}/ota.bin" ]; then
# if not exist %1\ota.bin goto error_x
echo "Error: Not found ${1}/ota.bin!"
exit 1
fi
#if exist %2\ota.bin del %2\ota.bin
#copy /b %1\ota.bin %2\ota.bin
cp -f "$1/ota.bin" "$2/ota.bin"
cd "$2"
JLinkGDBServer -device Cortex-M3 -if SWD -ir -endian little -speed 3500 &
#%3arm-none-eabi-gdb.exe -x gdb_img.jlink
${3}arm-none-eabi-gdb -x gdb_img.jlink
killall JLinkGDBServer
exit 0
#!/bin/bash
if [ ! -d "${1}" ]; then
# goto no_dir
JLinkGDBServer -device Cortex-M3 -if SWD -ir -endian little -speed 3500 &
arm-none-eabi-gdb -x gdb_ota.jlink
killall JLinkGDBServer
exit 0
fi
if [ ! -f "${1}/ota.bin" ]; then
echo "Error: Not found ${1}/ota.bin!"
exit 1
fi
cp -f "$1/ota.bin" "$2/ota.bin"
cd "$2"
JLinkGDBServer -device Cortex-M3 -if SWD -ir -endian little -speed 3500 &
${3}arm-none-eabi-gdb -x gdb_ota.jlink
killall JLinkGDBServer
exit 0
# Realtek module Core and platform.
# ------------------------------
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
name=RTL871x ARM (32-bits) Boards
version=0.0.1
# rtlmodule project settings
# ----------------------
rtlmodule.sdkpath={build.system.path}/sdk
rtlmodule.project={build.variant}
rtlmodule.libs={build.system.path}/libs
# rtlmodule compile variables
# ----------------------
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -mcpu=cortex-m3 -mthumb -Os -std=c++11 -fno-short-enums -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-short-enums -MMD
compiler.c.elf.cmd=arm-none-eabi-gcc
compiler.c.elf.flags= -mcpu=cortex-m3 -Os -Wl,--gc-sections -mcpu=cortex-m3 -mthumb --specs=nano.specs
compiler.S.flags=-c -g -x assembler-with-cpp
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-c -g -Os -std=gnu++11 -mcpu=cortex-m3 -mthumb -fno-short-enums -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-rtti -fno-short-enums -MMD
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.strip.cmd=arm-none-eabi-strip
compiler.nm.cmd=arm-none-eabi-nm
compiler.objcopy.cmd=arm-none-eabi-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O binary
compiler.elf2hex.cmd=arm-none-eabi-objcopy
compiler.ldflags=
compiler.size.cmd=arm-none-eabi-size
compiler.define=-DARDUINO=
# this can be overriden in boards.txt
build.extra_flags=
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
#compiler.c.elf.extra_flags= -Wl,--cref -Wl,--gc-sections -Wl,--entry=InfraStart -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning
compiler.c.elf.extra_flags= -Wl,--cref -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning -Wl,--undefined=InfraStart
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=
# rtlmodule include path
# ------------------
compiler.rtlmodule.c.include="-I{rtlmodule.sdkpath}/project/{rtlmodule.project}/inc" "-I{rtlmodule.sdkpath}/component/soc/realtek/common/bsp" "-I{rtlmodule.sdkpath}/component/os/freertos" "-I{rtlmodule.sdkpath}/component/os/freertos/freertos_v8.1.2/Source/include" "-I{rtlmodule.sdkpath}/component/os/freertos/freertos_v8.1.2/Source/portable/GCC/ARM_CM3" "-I{rtlmodule.sdkpath}/component/os/os_dep/include" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/misc/driver" "-I{rtlmodule.sdkpath}/component/common/api/network/include" "-I{rtlmodule.sdkpath}/component/common/api" "-I{rtlmodule.sdkpath}/component/common/api/platform" "-I{rtlmodule.sdkpath}/component/common/api/wifi" "-I{rtlmodule.sdkpath}/component/common/api/wifi/rtw_wpa_supplicant/src" "-I{rtlmodule.sdkpath}/component/common/application" "-I{rtlmodule.sdkpath}/component/common/media/framework" "-I{rtlmodule.sdkpath}/component/common/example" "-I{rtlmodule.sdkpath}/component/common/example/wlan_fast_connect" "-I{rtlmodule.sdkpath}/component/common/mbed/api" "-I{rtlmodule.sdkpath}/component/common/mbed/hal" "-I{rtlmodule.sdkpath}/component/common/mbed/hal_ext" "-I{rtlmodule.sdkpath}/component/common/mbed/targets/hal/rtl8195a" "-I{rtlmodule.sdkpath}/component/common/network" "-I{rtlmodule.sdkpath}/component/common/network/lwip/lwip_v1.4.1/port/realtek/freertos" "-I{rtlmodule.sdkpath}/component/common/network/lwip/lwip_v1.4.1/src/include" "-I{rtlmodule.sdkpath}/component/common/network/lwip/lwip_v1.4.1/src/include/lwip" "-I{rtlmodule.sdkpath}/component/common/network/lwip/lwip_v1.4.1/src/include/ipv4" "-I{rtlmodule.sdkpath}/component/common/network/lwip/lwip_v1.4.1/port/realtek" "-I{rtlmodule.sdkpath}/component/common/test" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/cmsis" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/cmsis/device" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/fwlib" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/fwlib/rtl8195a" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/misc/rtl_std_lib/include" "-I{rtlmodule.sdkpath}/component/common/drivers/wlan/realtek/include" "-I{rtlmodule.sdkpath}/component/common/drivers/wlan/realtek/src/osdep" "-I{rtlmodule.sdkpath}/component/common/drivers/wlan/realtek/src/hci" "-I{rtlmodule.sdkpath}/component/common/drivers/wlan/realtek/src/hal" "-I{rtlmodule.sdkpath}/component/common/drivers/wlan/realtek/src/hal/OUTSRC" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/fwlib/ram_lib/wlan/realtek/wlan_ram_map/rom" "-I{rtlmodule.sdkpath}/component/common/network/ssl/polarssl-1.3.8/include" "-I{rtlmodule.sdkpath}/component/common/network/ssl/ssl_ram_map/rom" "-I{rtlmodule.sdkpath}/component/common/utilities" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/misc/rtl_std_lib/include" "-I{rtlmodule.sdkpath}/component/soc/realtek/8195a/fwlib/ram_lib/usb_otg/include" "-I{rtlmodule.sdkpath}/component/common/video/v4l2/inc" "-I{rtlmodule.sdkpath}/component/common/media/codec" "-I{rtlmodule.sdkpath}/component/common/drivers/usb_class/host/uvc/inc" "-I{rtlmodule.sdkpath}/component/common/drivers/usb_class/device" "-I{rtlmodule.sdkpath}/component/common/drivers/usb_class/device/class" "-I{rtlmodule.sdkpath}/component/common/file_system/fatfs" "-I{rtlmodule.sdkpath}/component/common/file_system/fatfs/r0.10c/include" "-I{rtlmodule.sdkpath}/component/common/drivers/sdio/realtek/sdio_host/inc" "-I{rtlmodule.sdkpath}/component/common/audio" "-I{rtlmodule.sdkpath}/component/common/drivers/i2s" "-I{rtlmodule.sdkpath}/component/common/application/xmodem" "-I{rtlmodule.sdkpath}/component/common/network/mdns" "-I{rtlmodule.sdkpath}/component/common/network/libwsclient"
compiler.arduino.c.include="-I{build.core.path}"
compiler.rtlmodule.c.flags= -DCONFIG_PLATFORM_8195A -DARDUINO_SDK -DARDUINO_AMEBA {compiler.arduino.c.include} {compiler.rtlmodule.c.include}
# rtlmodule archieve list
# -------------------
compiler.rtlmodule.ar.list="{rtlmodule.libs}/lib_{build.variant}.a" "{rtlmodule.libs}/lib_lwip.a" "{rtlmodule.libs}/lib_mmf.a" "{rtlmodule.libs}/lib_p2p.a" "{rtlmodule.libs}/lib_rtlstd.a" "{rtlmodule.libs}/lib_rtsp.a" "{rtlmodule.libs}/lib_sdcard_v2.a" "{rtlmodule.libs}/lib_usbd.a" "{rtlmodule.libs}/lib_usbh.a" "{rtlmodule.libs}/lib_websocket.a" "{rtlmodule.libs}/lib_wlan.a" "{rtlmodule.libs}/lib_wps.a" "{rtlmodule.libs}/lib_xmodem.a" "{rtlmodule.libs}/lib_mdns.a" "{rtlmodule.libs}/lib_websocket.a" "{rtlmodule.libs}/lib_ssl.a"
#compiler.rtlmodule.ar.list="{build.variant.path}/lib_arlib.a" "{build.variant.path}/lib_lwip.a" "{build.variant.path}/lib_mdns.a" "{build.variant.path}/lib_p2p.a" "{build.variant.path}/lib_platform.a" "{build.variant.path}/lib_rtlstd.a" "{build.variant.path}/lib_sdcard.a" "{build.variant.path}/lib_uvc.a" "{build.variant.path}/lib_websocket.a" "{build.variant.path}/lib_wlan.a" "{build.variant.path}/lib_wps.a" "{build.variant.path}/lib_xmodem.a"
# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value.
build.usb_manufacturer="Unknown"
# rtlmodule compile patterns
# ---------------------
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {compiler.rtlmodule.c.flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.rtlmodule.c.flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-L{build.variant.path}/linker_scripts/gcc" "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map={build.path}/application.map" {compiler.c.elf.extra_flags} -o "{build.path}/application.axf" "-L{build.path}" -Wl,--start-group {object_files} -Wl,--end-group -Wl,--start-group "{build.path}/{archive_file}" {compiler.rtlmodule.ar.list} -Wl,--end-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
## Create nm map
recipe.nm.pattern=cp "{build.path}/{build.project_name}.axf" "{build.path}/application.axf"
## Create strip
recipe.strip.pattern="{compiler.path}{compiler.strip.cmd}" "{build.path}/{build.project_name}.axf"
## Create image
recipe.objcopy.hex.cmd=postbuild_img2_arduino_windows.exe
recipe.objcopy.hex.cmd.windows=postbuild_img2_arduino_windows.exe
recipe.objcopy.hex.cmd.macosx=postbuild_img2_arduino_mac
recipe.objcopy.hex.cmd.linux=postbuild_img2_arduino_linux
recipe.objcopy.hex.imagepath={build.path}\application.axf
recipe.objcopy.hex.imagepath.macosx="{build.path}/application.axf"
recipe.objcopy.hex.imagepath.linux="{build.path}/application.axf"
recipe.objcopy.hex.pattern="{runtime.tools.ameba_tools.path}/{recipe.objcopy.hex.cmd}" "{runtime.tools.ameba_tools.path}" "{recipe.objcopy.hex.imagepath}" "{compiler.path}" "{build.variant.path}/{build.sym_bklist}"
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/application.axf"
#recipe.size.regex=\.text\s+([0-9]+).*
recipe.size.regex=^(?:\.ram_image1.text|\.ram_image2.text|\.image3)\s+([0-9]+).*
# rtlmodule Uploader tools
# -------------------
tools.jlink.upload.params.verbose=
tools.jlink.cmd=jlink_upload
tools.jlink.cmd.windows=jlink_upload.cmd
tools.jlink.cmd.macosx=
tools.jlink.path.macosx=
tools.jlink.path.linux=
tools.jlink.path.linux64=
tools.jlink.path={runtime.tools.ameba_tools.path}
tools.jlink.upload.params.quiet=
tools.jlink.upload.pattern="{runtime.platform.path}/tools/{tools.jlink.cmd}" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools"
tools.jlink.upload.pattern.linux="{runtime.platform.path}/tools/jlink_upload.sh" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools"
tools.jlinkam.upload.params.verbose=
tools.jlinkam.cmd=jlink_uploadam
tools.jlinkam.cmd.windows=jlink_uploadam.cmd
tools.jlinkam.cmd.macosx=
tools.jlinkam.path.macosx=
tools.jlinkam.path.linux=
tools.jlinkam.path.linux64=
tools.jlinkam.path={runtime.tools.ameba_tools.path}
tools.jlinkam.upload.params.quiet=
tools.jlinkam.upload.pattern="{runtime.platform.path}/tools/{tools.jlinkam.cmd}" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools"
tools.network.upload.params.verbose=
tools.network.cmd=upload_ota
tools.network.cmd.windows="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}\ota.bin"
tools.network.cmd.macosx=
tools.network.path.macosx=
tools.network.path.linux="{runtime.tools.ameba_tools.path}/upload_ota_linux" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.path.linux64=
tools.network.path={runtime.tools.ameba_tools.path}
tools.network.upload.params.quiet=
tools.network.upload.pattern="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.upload.pattern.linux="{runtime.tools.ameba_tools.path}/upload_ota_linux" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.upload.network_pattern="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.upload.network_pattern.linux="{runtime.tools.ameba_tools.path}/upload_ota_linux" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.network_pattern.windows="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.network_pattern.macosx="{runtime.tools.ameba_tools.path}/upload_ota_mac" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.network.network_pattern.linux="{runtime.tools.ameba_tools.path}/upload_ota_linux" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.jlgdbota.upload.params.verbose=
tools.jlgdbota.cmd=JLinkGDB_OTA
tools.jlgdbota.cmd.windows=JLinkGDB_OTA.cmd
tools.jlgdbota.cmd.macosx=
tools.jlgdbota.path.macosx=
tools.jlgdbota.path.linux=
tools.jlgdbota.path.linux64=
tools.jlgdbota.path={runtime.tools.ameba_tools.path}
tools.jlgdbota.upload.params.quiet=
tools.jlgdbota.upload.pattern="{runtime.platform.path}/tools/JLinkGDB_OTA.cmd" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools" "{runtime.tools.arm-none-eabi-gcc.path}/bin/"
tools.jlgdbota.upload.pattern.linux="{runtime.platform.path}/tools/JLinkGDB_OTA.sh" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools" "{runtime.tools.arm-none-eabi-gcc.path}/bin/"
tools.jlgdbimg.upload.params.verbose=
tools.jlgdbimg.cmd=JLinkGDB_IMG
tools.jlgdbimg.cmd.windows=JLinkGDB_IMG.cmd
tools.jlgdbimg.cmd.macosx=
tools.jlgdbimg.path.macosx=
tools.jlgdbimg.path.linux=
tools.jlgdbimg.path.linux64=
tools.jlgdbimg.path={runtime.tools.ameba_tools.path}
tools.jlgdbimg.upload.params.quiet=
tools.jlgdbimg.upload.pattern="{runtime.platform.path}/tools/{tools.jlgdbimg.cmd}" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools" "{runtime.tools.arm-none-eabi-gcc.path}/bin/"
tools.jlgdbimg.upload.pattern.linux="{runtime.platform.path}/tools/JLinkGDB_IMG.sh" "{runtime.tools.ameba_tools.path}" "{runtime.platform.path}/tools" "{runtime.tools.arm-none-eabi-gcc.path}/bin/"
tools.dapimg.upload.params.verbose=
tools.dapimg.upload.params.quiet=
tools.dapimg.upload.pattern="{runtime.tools.ameba_tools.path}/upload_dap.sh" {upload.verbose}
tools.dapimg.upload.pattern.windows="{runtime.tools.ameba_tools.path}/upload_dap.exe" "{runtime.tools.ameba_tools.path}\ram_all.bin"{upload.verbose}
tools.dapimg.upload.pattern.macosx="{runtime.tools.ameba_tools.path}/upload_dap_macosx" "{runtime.tools.ameba_tools.path}/ram_all.bin"{upload.verbose}
tools.dapimg.upload.pattern.linux="{runtime.tools.ameba_tools.path}/upload_dap_linux" "{runtime.tools.ameba_tools.path}/ram_all.bin"{upload.verbose}
tools.dapimg.upload.network_pattern="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}\ota.bin"
tools.dapimg.upload.network_pattern.windows="{runtime.tools.ameba_tools.path}/upload_ota.exe" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}\ota.bin"
tools.dapimg.upload.network_pattern.macosx="{runtime.tools.ameba_tools.path}/upload_ota_macosx" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
tools.dapimg.upload.network_pattern.linux="{runtime.tools.ameba_tools.path}/upload_ota_linux" -i "{serial.port}" -p "{network.port}" -f "{runtime.tools.ameba_tools.path}/ota.bin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment