Skip to content

Commit eb71da0

Browse files
committed
Add RAK_PATCH_V2
1 parent 32f4280 commit eb71da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4038
-1
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import sys
2+
import struct
3+
4+
Import("env")
5+
6+
# Parse input and create UF2 file
7+
def create_uf2(source, target, env):
8+
# source_hex = target[0].get_abspath()
9+
source_hex = target[0].get_string(False)
10+
source_hex = '.\\'+source_hex
11+
print("#########################################################")
12+
print("Create UF2 from "+source_hex)
13+
print("#########################################################")
14+
# print("Source: " + source_hex)
15+
target = source_hex.replace(".hex", "")
16+
target = target + ".uf2"
17+
# print("Target: " + target)
18+
19+
with open(source_hex, mode='rb') as f:
20+
inpbuf = f.read()
21+
22+
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
23+
24+
write_file(target, outbuf)
25+
print("#########################################################")
26+
print(target + " is ready to flash to target device")
27+
print("#########################################################")
28+
29+
30+
# Add callback after .hex file was created
31+
env.AddPostAction("$BUILD_DIR/${PROGNAME}.hex", create_uf2)
32+
33+
# UF2 creation taken from uf2conv.py
34+
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
35+
UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected
36+
UF2_MAGIC_END = 0x0AB16F30 # Ditto
37+
38+
familyid = 0xADA52840
39+
40+
41+
class Block:
42+
def __init__(self, addr):
43+
self.addr = addr
44+
self.bytes = bytearray(256)
45+
46+
def encode(self, blockno, numblocks):
47+
global familyid
48+
flags = 0x0
49+
if familyid:
50+
flags |= 0x2000
51+
hd = struct.pack("<IIIIIIII",
52+
UF2_MAGIC_START0, UF2_MAGIC_START1,
53+
flags, self.addr, 256, blockno, numblocks, familyid)
54+
hd += self.bytes[0:256]
55+
while len(hd) < 512 - 4:
56+
hd += b"\x00"
57+
hd += struct.pack("<I", UF2_MAGIC_END)
58+
return hd
59+
60+
61+
def write_file(name, buf):
62+
with open(name, "wb") as f:
63+
f.write(buf)
64+
# print("Wrote %d bytes to %s." % (len(buf), name))
65+
66+
67+
def convert_from_hex_to_uf2(buf):
68+
global appstartaddr
69+
appstartaddr = None
70+
upper = 0
71+
currblock = None
72+
blocks = []
73+
for line in buf.split('\n'):
74+
if line[0] != ":":
75+
continue
76+
i = 1
77+
rec = []
78+
while i < len(line) - 1:
79+
rec.append(int(line[i:i+2], 16))
80+
i += 2
81+
tp = rec[3]
82+
if tp == 4:
83+
upper = ((rec[4] << 8) | rec[5]) << 16
84+
elif tp == 2:
85+
upper = ((rec[4] << 8) | rec[5]) << 4
86+
assert (upper & 0xffff) == 0
87+
elif tp == 1:
88+
break
89+
elif tp == 0:
90+
addr = upper | (rec[1] << 8) | rec[2]
91+
if appstartaddr == None:
92+
appstartaddr = addr
93+
i = 4
94+
while i < len(rec) - 1:
95+
if not currblock or currblock.addr & ~0xff != addr & ~0xff:
96+
currblock = Block(addr & ~0xff)
97+
blocks.append(currblock)
98+
currblock.bytes[addr & 0xff] = rec[i]
99+
addr += 1
100+
i += 1
101+
numblocks = len(blocks)
102+
resfile = b""
103+
for i in range(0, numblocks):
104+
resfile += blocks[i].encode(i, numblocks)
105+
return resfile
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
[platformio]
11+
default_envs =
12+
rak4630
13+
rak11200
14+
rak3112
15+
rak11300
16+
boards_dir = rakwireless/boards
17+
18+
[common]
19+
build_flags =
20+
-D SW_VERSION_1=1 ; major version increase on API change / not backwards compatible
21+
-D SW_VERSION_2=0 ; minor version increase on API change / backward compatible
22+
-D SW_VERSION_3=11 ; patch version increase on bugfix, no affect on API
23+
-D LIB_DEBUG=0 ; 0 Disable LoRaWAN debug output
24+
-D API_DEBUG=0 ; 0 Disable WisBlock API debug output
25+
-D BASE_BOARD=0 ; 1 = RAK19003 0 = other base boards
26+
monitor_speed = 115200
27+
lib_deps =
28+
beegee-tokyo/SX126x-Arduino
29+
beegee-tokyo/WisBlock-API-V2
30+
electroniccats/CayenneLPP
31+
32+
[env:rak4630]
33+
platform = nordicnrf52
34+
board = rak4630
35+
framework = arduino
36+
build_src_filter = ${env.build_src_filter}+<../rakwireless/variants/rak4630>
37+
build_flags =
38+
; -DCFG_DEBUG=1
39+
${common.build_flags}
40+
-Irakwireless/variants/rak4630
41+
-D NO_BLE_LED=1
42+
-D MY_DEBUG=0 ; 0 Disable application debug output
43+
lib_deps =
44+
${common.lib_deps}
45+
extra_scripts =
46+
pre:rename.py
47+
post:create_uf2.py
48+
49+
[env:rak11200]
50+
platform = espressif32
51+
board = rak11200
52+
framework = arduino
53+
board_build.partitions = huge_app.csv
54+
build_flags =
55+
; -DCFG_DEBUG=1
56+
${common.build_flags}
57+
-I rakwireless/variants/rak11200
58+
-DBOARD_HAS_PSRAM
59+
-mfix-esp32-psram-cache-issue
60+
-D NO_BLE_LED=1
61+
-D MY_DEBUG=1 ; 0 Disable application debug output
62+
lib_deps =
63+
${common.lib_deps}
64+
h2zero/NimBLE-Arduino
65+
66+
[env:rak3112]
67+
platform = espressif32
68+
board = rak3112
69+
framework = arduino
70+
board_build.partitions = huge_app.csv
71+
build_flags =
72+
${common.build_flags}
73+
-I rakwireless/variants/rak3112
74+
-D _VARIANT_RAK3112_=1
75+
-DBOARD_HAS_PSRAM
76+
-mfix-esp32-psram-cache-issue
77+
-D NO_BLE_LED=1
78+
-D MY_DEBUG=1 ; 0 Disable application debug output
79+
lib_deps =
80+
${common.lib_deps}
81+
82+
[env:rak11300]
83+
platform = https://github.com/maxgerhardt/platform-raspberrypi
84+
board_build.core = earlephilhower
85+
board = rakwireless_rak11300
86+
framework = arduino
87+
build_flags =
88+
-D ARDUINO_RAKWIRELESS_RAK11300=1
89+
${common.build_flags}
90+
-I rakwireless/variants/rak11300
91+
-D NO_BLE_LED=1
92+
-D MY_DEBUG=1 ; 0 Disable application debug output
93+
; WisBlock definitions
94+
-D WB_IO1=6
95+
-D WB_IO2=22
96+
-D WB_IO3=7
97+
-D WB_IO4=28
98+
-D WB_IO5=9
99+
-D WB_IO6=8
100+
-D WB_A0=26
101+
-D WB_A1=27
102+
-D PIN_LED1=23
103+
-D PIN_LED2=24
104+
-D LED_BUILTIN=23
105+
-D LED_CONN=24
106+
-D LED_GREEN=23
107+
-D LED_BLUE=24
108+
lib_deps =
109+
${common.lib_deps}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"build": {
3+
"arduino":{
4+
"ldscript": "esp32_out.ld"
5+
},
6+
"core": "esp32",
7+
"extra_flags": "-DARDUINO_ESP32_DEV",
8+
"f_cpu": "240000000L",
9+
"f_flash": "40000000L",
10+
"flash_mode": "dio",
11+
"mcu": "esp32",
12+
"variant": "rak11200"
13+
},
14+
"connectivity": [
15+
"wifi",
16+
"bluetooth",
17+
"ethernet",
18+
"can"
19+
],
20+
"frameworks": [
21+
"arduino",
22+
"espidf"
23+
],
24+
"name": "WisCore RAK11200 Board",
25+
"upload": {
26+
"flash_size": "4MB",
27+
"maximum_ram_size": 327680,
28+
"maximum_size": 4194304,
29+
"protocols": [
30+
"esptool",
31+
"espota",
32+
"ftdi"
33+
],
34+
"require_upload_port": true,
35+
"speed": 460800
36+
},
37+
"url": "https://www.rakwireless.com",
38+
"vendor": "RAKwireless"
39+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"build": {
3+
"core": "arduino",
4+
"cpu": "cortex-m0plus",
5+
"extra_flags": "-D ARDUINO_RASPBERRY_PI_PICO -DARDUINO_ARCH_RP2040",
6+
"f_cpu": "133000000L",
7+
"hwids": [
8+
[
9+
"0x2E8A",
10+
"0x00C0"
11+
]
12+
],
13+
"mcu": "rp2040",
14+
"variant": "rak11300"
15+
},
16+
"debug": {
17+
"jlink_device": "RP2040_M0_0",
18+
"openocd_target": "rp2040.cfg",
19+
"svd_path": "rp2040.svd"
20+
},
21+
"frameworks": [
22+
"arduino"
23+
],
24+
"name": "WisBlock RAK11300",
25+
"upload": {
26+
"maximum_ram_size": 270336,
27+
"maximum_size": 2097152,
28+
"require_upload_port": true,
29+
"native_usb": true,
30+
"use_1200bps_touch": true,
31+
"wait_for_upload_port": false,
32+
"protocol": "picotool",
33+
"protocols": [
34+
"cmsis-dap",
35+
"jlink",
36+
"raspberrypi-swd",
37+
"picotool"
38+
]
39+
},
40+
"url": "https://docs.rakwireless.com/",
41+
"vendor": "RAKwireless"
42+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld",
5+
"memory_type": "qio_opi"
6+
},
7+
"core": "esp32",
8+
"extra_flags": [
9+
"-DRAK3112",
10+
"-DARDUINO_USB_CDC_ON_BOOT=1",
11+
"-DARDUINO_USB_MODE=1",
12+
"-DARDUINO_RUNNING_CORE=1",
13+
"-DARDUINO_EVENT_RUNNING_CORE=1",
14+
"-DBOARD_HAS_PSRAM"
15+
],
16+
"f_cpu": "240000000L",
17+
"f_flash": "80000000L",
18+
"flash_mode": "dio",
19+
"hwids": [
20+
[
21+
"0x303A",
22+
"0x1001"
23+
]
24+
],
25+
"mcu": "esp32s3",
26+
"variant": "rak3112"
27+
},
28+
"connectivity": [
29+
"wifi",
30+
"bluetooth"
31+
],
32+
"debug": {
33+
"openocd_target": "esp32s3.cfg"
34+
},
35+
"frameworks": [
36+
"arduino",
37+
"espidf"
38+
],
39+
"name": "RAKwireless RAK3112",
40+
"upload": {
41+
"flash_size": "16MB",
42+
"maximum_ram_size": 327680,
43+
"maximum_size": 16777216,
44+
"use_1200bps_touch": true,
45+
"wait_for_upload_port": false,
46+
"require_upload_port": true,
47+
"speed": 921600
48+
},
49+
"url": "http://www.rakwireless.com/",
50+
"vendor": "RAKwireless"
51+
}

0 commit comments

Comments
 (0)