Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 055728a

Browse files
committed
Merge release updates from master
1 parent 00f82eb commit 055728a

File tree

12 files changed

+38
-99
lines changed

12 files changed

+38
-99
lines changed

Jenkinsfile

+5-17
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ node {
3333
stage(board) {
3434
def parallelSteps = [:]
3535
def board_u = board.toUpperCase()
36-
if (board_u == "LOPY" || board_u == "FIPY" || board_u == "LOPY4") {
37-
parallelSteps[board+"_868"] = boardBuild(board+"_868")
38-
parallelSteps[board+"_915"] = boardBuild(board+"_915")
39-
}
40-
else{
41-
parallelSteps[board] = boardBuild(board)
42-
}
36+
parallelSteps[board] = boardBuild(board)
4337
parallel parallelSteps
4438
}
4539
}
@@ -71,30 +65,23 @@ stage ('Test'){
7165
def boardBuild(name) {
7266
def name_u = name.toUpperCase()
7367
def name_short = name_u.split('_')[0]
74-
def lora_band = ""
75-
if (name_u == "LOPY_868" || name_u == "FIPY_868" || name_u == "LOPY4_868") {
76-
lora_band = " LORA_BAND=USE_BAND_868"
77-
}
78-
else if (name_u == "LOPY_915" || name_u == "FIPY_915" || name_u == "LOPY4_915") {
79-
lora_band = " LORA_BAND=USE_BAND_915"
80-
}
8168
def app_bin = name.toLowerCase() + '.bin'
8269
return {
8370
release_dir = "${JENKINS_HOME}/release/${JOB_NAME}/" + PYCOM_VERSION + "/" + GIT_TAG + "/"
8471
sh '''export PATH=$PATH:/opt/xtensa-esp32-elf/bin;
8572
export IDF_PATH=${WORKSPACE}/esp-idf;
8673
cd esp32;
87-
make clean BOARD=''' + name_short + lora_band
74+
make clean BOARD=''' + name_short
8875

8976
sh '''export PATH=$PATH:/opt/xtensa-esp32-elf/bin;
9077
export IDF_PATH=${WORKSPACE}/esp-idf;
9178
cd esp32;
92-
make TARGET=boot -j2 BOARD=''' + name_short + lora_band
79+
make TARGET=boot -j2 BOARD=''' + name_short
9380

9481
sh '''export PATH=$PATH:/opt/xtensa-esp32-elf/bin;
9582
export IDF_PATH=${WORKSPACE}/esp-idf;
9683
cd esp32;
97-
make TARGET=app -j2 BOARD=''' + name_short + lora_band
84+
make TARGET=app -j2 BOARD=''' + name_short
9885

9986
sh '''cd esp32/build/'''+ name_u +'''/release;
10087
mkdir -p firmware_package;
@@ -172,3 +159,4 @@ def get_remote_name(short_name) {
172159
def get_device_name(short_name) {
173160
return "/dev/serial/by-id/usb-" + short_name + "-if00"
174161
}
162+

esp32/boards/FIPY/FIPY_868/script renamed to esp32/boards/FIPY/FIPY/script

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
["e", "0x1C1000", "0x40000"],
1010
["w", "0x1000", "bootloader.bin"],
1111
["w", "0x8000", "partitions.bin"],
12-
["w", "0x10000", "fipy_868.bin"]
12+
["w", "0x10000", "fipy.bin"]
1313
]

esp32/boards/FIPY/FIPY_915/script renamed to esp32/boards/LOPY/LOPY/script

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
["e", "0x1C1000", "0x40000"],
1010
["w", "0x1000", "bootloader.bin"],
1111
["w", "0x8000", "partitions.bin"],
12-
["w", "0x10000", "fipy_915.bin"]
12+
["w", "0x10000", "lopy.bin"]
1313
]

esp32/boards/LOPY/LOPY_915/script

-13
This file was deleted.

esp32/boards/LOPY/LOPY_868/script renamed to esp32/boards/LOPY4/LOPY4/script

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
["e", "0x1C1000", "0x40000"],
1010
["w", "0x1000", "bootloader.bin"],
1111
["w", "0x8000", "partitions.bin"],
12-
["w", "0x10000", "lopy_868.bin"]
12+
["w", "0x10000", "lopy4.bin"]
1313
]

esp32/boards/LOPY4/LOPY4_868/script

-13
This file was deleted.

esp32/boards/LOPY4/LOPY4_915/script

-13
This file was deleted.

esp32/mods/modlora.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ static void lora_validate_device_class (DeviceClass_t device_class) {
12231223

12241224
static void lora_validate_region (LoRaMacRegion_t region) {
12251225
if (region != LORAMAC_REGION_AS923 && region != LORAMAC_REGION_AU915
1226-
&& region != LORAMAC_REGION_EU868 && region != LORAMAC_REGION_US915_HYBRID) {
1226+
&& region != LORAMAC_REGION_EU868 && region != LORAMAC_REGION_US915) {
12271227
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid region %d", region));
12281228
}
12291229
}
@@ -1409,7 +1409,11 @@ static mp_obj_t lora_init_helper(lora_obj_t *self, const mp_arg_val_t *args) {
14091409
lora_validate_mode (cmd_data.info.init.stack_mode);
14101410

14111411
// we need to know the region first
1412-
cmd_data.info.init.region = args[14].u_int;
1412+
if (args[14].u_obj == MP_OBJ_NULL) {
1413+
cmd_data.info.init.region = config_get_lora_region();
1414+
} else {
1415+
cmd_data.info.init.region = mp_obj_get_int(args[14].u_obj);
1416+
}
14131417
lora_validate_region(cmd_data.info.init.region);
14141418
// we need to do it here in advance for the rest of the validation to work
14151419
lora_obj.region = cmd_data.info.init.region;
@@ -1501,7 +1505,7 @@ STATIC const mp_arg_t lora_init_args[] = {
15011505
{ MP_QSTR_public, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
15021506
{ MP_QSTR_tx_retries, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 2} },
15031507
{ MP_QSTR_device_class, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = CLASS_A} },
1504-
{ MP_QSTR_region, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = LORAMAC_REGION_EU868} },
1508+
{ MP_QSTR_region, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
15051509
};
15061510
STATIC mp_obj_t lora_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *all_args) {
15071511
// parse args
@@ -2105,7 +2109,7 @@ STATIC const mp_map_elem_t lora_locals_dict_table[] = {
21052109
{ MP_OBJ_NEW_QSTR(MP_QSTR_AS923), MP_OBJ_NEW_SMALL_INT(LORAMAC_REGION_AS923) },
21062110
{ MP_OBJ_NEW_QSTR(MP_QSTR_AU915), MP_OBJ_NEW_SMALL_INT(LORAMAC_REGION_AU915) },
21072111
{ MP_OBJ_NEW_QSTR(MP_QSTR_EU868), MP_OBJ_NEW_SMALL_INT(LORAMAC_REGION_EU868) },
2108-
{ MP_OBJ_NEW_QSTR(MP_QSTR_US915), MP_OBJ_NEW_SMALL_INT(LORAMAC_REGION_US915_HYBRID) },
2112+
{ MP_OBJ_NEW_QSTR(MP_QSTR_US915), MP_OBJ_NEW_SMALL_INT(LORAMAC_REGION_US915) },
21092113
};
21102114

21112115
STATIC MP_DEFINE_CONST_DICT(lora_locals_dict, lora_locals_dict_table);

esp32/mods/modpycom.c

-14
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,6 @@ STATIC mp_obj_t mod_pycom_wifi_pwd (mp_uint_t n_args, const mp_obj_t *args) {
230230
}
231231
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_wifi_pwd_obj, 0, 1, mod_pycom_wifi_pwd);
232232

233-
STATIC mp_obj_t mod_pycom_lora_country (mp_uint_t n_args, const mp_obj_t *args) {
234-
if (n_args) {
235-
const char *lora_country = mp_obj_str_get_str(args[0]);
236-
config_set_lora_country ((const uint8_t*)lora_country);
237-
} else {
238-
uint8_t lora_country[32];
239-
config_get_lora_country(lora_country);
240-
return mp_obj_new_str((const char*)lora_country,strlen((const char*)lora_country),false);
241-
}
242-
return mp_const_none;
243-
}
244-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_pycom_lora_country_obj, 0, 1, mod_pycom_lora_country);
245-
246233
STATIC mp_obj_t mod_pycom_heartbeat_on_boot (mp_uint_t n_args, const mp_obj_t *args) {
247234
if (n_args) {
248235
config_set_heartbeat_on_boot (mp_obj_is_true(args[0]));
@@ -269,7 +256,6 @@ STATIC const mp_map_elem_t pycom_module_globals_table[] = {
269256
{ MP_OBJ_NEW_QSTR(MP_QSTR_wifi_on_boot), (mp_obj_t)&mod_pycom_wifi_on_boot_obj },
270257
{ MP_OBJ_NEW_QSTR(MP_QSTR_wifi_ssid), (mp_obj_t)&mod_pycom_wifi_ssid_obj },
271258
{ MP_OBJ_NEW_QSTR(MP_QSTR_wifi_pwd), (mp_obj_t)&mod_pycom_wifi_pwd_obj },
272-
{ MP_OBJ_NEW_QSTR(MP_QSTR_lora_country), (mp_obj_t)&mod_pycom_lora_country_obj },
273259
{ MP_OBJ_NEW_QSTR(MP_QSTR_heartbeat_on_boot), (mp_obj_t)&mod_pycom_heartbeat_on_boot_obj },
274260
};
275261

esp32/pycom_config.c

+8-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static pycom_config_block_t pycom_config_block;
2525
void config_init0 (void) {
2626
// read the config struct from flash
2727
spi_flash_read(CONFIG_DATA_FLASH_ADDR, (void *)&pycom_config_block, sizeof(pycom_config_block));
28-
printf("Size of configuration block: %d\n",sizeof(pycom_config_block));
2928
}
3029

3130
bool config_set_lpwan_mac (const uint8_t *mac) {
@@ -73,16 +72,15 @@ void config_get_sigfox_private_key (uint8_t *private_key) {
7372
memcpy(private_key, pycom_config_block.lpwan_config.sigfox_private_key, sizeof(pycom_config_block.lpwan_config.sigfox_private_key));
7473
}
7574

76-
bool config_set_lora_country (const uint8_t *lora_country) {
77-
memcpy(pycom_config_block.lpwan_config.lora_country, lora_country, sizeof(pycom_config_block.lpwan_config.lora_country));
75+
bool config_set_lora_region (uint8_t lora_region) {
76+
if (pycom_config_block.lpwan_config.lora_region != lora_region) {
77+
pycom_config_block.lpwan_config.lora_region = lora_region;
78+
}
7879
return config_write();
7980
}
8081

81-
void config_get_lora_country (uint8_t *lora_country) {
82-
memcpy( lora_country, pycom_config_block.lpwan_config.lora_country, sizeof(pycom_config_block.lpwan_config.lora_country));
83-
if (lora_country[0]==0xFF) {
84-
lora_country[0]=0x00;
85-
}
82+
uint8_t config_get_lora_region (void) {
83+
return (pycom_config_block.lpwan_config.lora_region == 0xff) ? 5:pycom_config_block.lpwan_config.lora_region;
8684
}
8785

8886
bool config_set_wifi_on_boot (uint8_t wifi_on_boot) {
@@ -117,7 +115,7 @@ bool config_set_wifi_ssid (const uint8_t *wifi_ssid) {
117115
void config_get_wifi_ssid (uint8_t *wifi_ssid) {
118116
memcpy( wifi_ssid, pycom_config_block.wifi_config.wifi_ssid, sizeof(pycom_config_block.wifi_config.wifi_ssid));
119117
if (wifi_ssid[0]==0xff) {
120-
wifi_ssid[0]=0x0;
118+
wifi_ssid[0]=0x0;
121119
}
122120
}
123121

@@ -129,12 +127,11 @@ bool config_set_wifi_pwd (const uint8_t *wifi_pwd) {
129127
void config_get_wifi_pwd (uint8_t *wifi_pwd) {
130128
memcpy( wifi_pwd, pycom_config_block.wifi_config.wifi_pwd, sizeof(pycom_config_block.wifi_config.wifi_pwd));
131129
if (wifi_pwd[0]==0xff) {
132-
wifi_pwd[0]=0x0;
130+
wifi_pwd[0]=0x0;
133131
}
134132
}
135133

136134
static bool config_write (void) {
137-
printf("Size of configuration block: %d\n",sizeof(pycom_config_block));
138135
// erase the block first
139136
if (ESP_OK == spi_flash_erase_sector(CONFIG_DATA_FLASH_BLOCK)) {
140137
// then write it

esp32/pycom_config.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct {
2727
uint8_t sigfox_pac[8];
2828
uint8_t sigfox_private_key[16];
2929
uint8_t sigfox_public_key[16];
30-
uint8_t lora_country[33];
30+
uint8_t lora_region;
3131
} pycom_lpwan_config_t;
3232

3333
typedef struct {
@@ -50,7 +50,7 @@ typedef struct {
5050
uint8_t pycom_hw_version;
5151
uint8_t pycom_sw_version[12];
5252
uint8_t pycom_reserved[335];
53-
uint8_t pycom_dummy[228];
53+
uint8_t pycom_dummy[258];
5454
} pycom_config_t;
5555

5656
typedef struct {
@@ -101,9 +101,9 @@ bool config_set_wifi_pwd(const uint8_t *wifi_pwd);
101101

102102
void config_get_wifi_pwd(uint8_t *wifi_pwd);
103103

104-
bool config_set_lora_country(const uint8_t *lpwan_country);
104+
bool config_set_lora_region (uint8_t lora_region);
105105

106-
void config_get_lora_country(uint8_t *lpwan_country);
106+
uint8_t config_get_lora_region (void);
107107

108108
int config_size(void);
109109

esp32/tools/pypic.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import struct
1010
import time
1111

12-
__version__ = '0.9.1'
12+
__version__ = '0.9.2'
1313

1414
CMD_PEEK = (0x0)
1515
CMD_POKE = (0x01)
@@ -131,24 +131,27 @@ def reset_pycom_module(self):
131131
self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 5))
132132
# drive RC5 low
133133
self.mask_bits_in_memory(PORTC_ADDR, ~(1 << 5))
134-
time.sleep(0.25)
134+
time.sleep(0.2)
135135
# drive RC5 high
136136
self.set_bits_in_memory(PORTC_ADDR, 1 << 5)
137137
time.sleep(0.1)
138+
# make RC5 an input
139+
self.set_bits_in_memory(TRISC_ADDR, 1 << 5)
138140

139141
def enter_pycom_programming_mode(self):
140142
# make RC0 an output
141143
self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 0))
142144
# set RC0 low
143145
self.mask_bits_in_memory(PORTC_ADDR, ~(1 << 0))
146+
# perform reset
144147
self.reset_pycom_module()
148+
# We should keep RC0 low at this point in case someone
149+
# presses the reset button before the firmware upgrade
150+
# as this is mandatory for the regular expansion board
145151

146152
def exit_pycom_programming_mode(self):
147-
# make RC0 an output
148-
self.mask_bits_in_memory(TRISC_ADDR, ~(1 << 0))
149-
# set RC0 high
150-
self.set_bits_in_memory(PORTC_ADDR, 1 << 0)
151153
# make RC0 an input
154+
# This will prevent issues with the RGB LED
152155
self.set_bits_in_memory(TRISC_ADDR, 1 << 0)
153156
self.reset_pycom_module()
154157

@@ -160,7 +163,7 @@ def close(self):
160163

161164

162165
def main(args):
163-
parser = argparse.ArgumentParser(description='Sends internal commands to pu the Pycom module in programming mode')
166+
parser = argparse.ArgumentParser(description='Sends internal commands to put the Pycom module in programming mode')
164167
parser.add_argument('-p', '--port', metavar='PORT', help='the serial port used to communicate with the PIC')
165168
parser.add_argument('--enter', action='store_true', help='enter programming mode')
166169
parser.add_argument('--exit', action='store_true', help='exit programming mode')

0 commit comments

Comments
 (0)