Skip to content

Commit 40a7de2

Browse files
authored
Merge pull request #504 from tock/lr1110-quickfixes
Lr1110 quickfixes
2 parents 60d3652 + 1c01239 commit 40a7de2

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

lr1110/Makefile.setup

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TOCK_USERLAND_BASE_DIR ?= ..
22
LR1110_DIR = $(TOCK_USERLAND_BASE_DIR)/lr1110/lr1110
33

4-
VERSION_HASH := 7c33c9ef136c841a7b44f530d2415789c86f48af
4+
VERSION_HASH := e34742993932c97731f513ffa3028d284b163d31
55

66
SEEED_DIR := $(LR1110_DIR)/seeed
77
ZIP_FILE := $(SEEED_DIR).zip
@@ -27,12 +27,13 @@ $(LR1110_DIR)/radio_planner.c: $(SEEED_DIR)/smtc_hal/smtc_modem_hal.c
2727
cp $(LR1110_DIR)/seeed/lora_basics_modem/smtc_modem_core/radio_planner/src/radio_planner.c $(LR1110_DIR)/radio_planner.c
2828
cd $(LR1110_DIR); patch -p0 < ../radio_planner.patch
2929

30-
$(SEEED_DIR)/smtc_hal/smtc_modem_hal.c:
31-
curl -L --output $(ZIP_FILE) "https://codeload.github.com/Seeed-Studio/Seeed_Wio_WM1110_Dev_Board/zip/$(VERSION_HASH)"
32-
unzip -q $(ZIP_FILE) -d $(SEEED_DIR)
33-
rm -f $(ZIP_FILE) # Remove zip file after unzip
34-
mv $(EXTRACTED_DIR)/* $(SEEED_DIR)/
35-
rmdir $(EXTRACTED_DIR) # move unzipped code to SEEED_DIR, remove original directory
30+
31+
$(SEEED_DIR):
32+
mkdir -p $(SEEED_DIR)
33+
34+
$(SEEED_DIR)/smtc_hal/smtc_modem_hal.c: | $(SEEED_DIR)
35+
curl -L "https://github.com/Seeed-Studio/Seeed_Wio_WM1110_Dev_Board/archive/$(VERSION_HASH).tar.gz" | \
36+
tar --strip-components=1 -xz -C $(SEEED_DIR)
3637
touch $(SEEED_DIR)
3738
# Need to remove certain system headers because we provide our own.
3839
rm $(SEEED_DIR)/smtc_hal/inc/smtc_hal_flash.h

lr1110/lr1110/src_changed/lr11xx_hal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include <stdint.h> // C99 types
4141
#include <stdbool.h> // bool type
42+
#include <string.h> // memset
4243

4344
#include <libtock-sync/services/alarm.h>
4445
#include <libtock-sync/net/lora_phy.h>

lr1110/lr1110/src_changed/smtc_hal_flash.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <stdlib.h>
2+
13
#include <libtock-sync/storage/nonvolatile_storage.h>
24

35
#include "smtc_hal.h"
@@ -26,12 +28,16 @@ smtc_hal_status_t hal_flash_write_buffer( uint32_t addr, const uint8_t* buffer,
2628
void hal_flash_read_buffer( uint32_t addr, uint8_t* buffer, uint32_t size )
2729
{
2830
returncode_t ret;
29-
3031
int length_read = 0;
31-
ret = libtocksync_nonvolatile_storage_read(addr, size, buffer, size, &length_read);
32-
if (ret != RETURNCODE_SUCCESS) return SMTC_HAL_FAILURE;
33-
34-
return SMTC_HAL_SUCCESS;
32+
int max_tries = 3;
33+
34+
do {
35+
ret = libtocksync_nonvolatile_storage_read(addr, size, buffer, size, &length_read);
36+
max_tries--;
37+
if (max_tries == 0) {
38+
exit(ret);
39+
}
40+
} while (ret != RETURNCODE_SUCCESS);
3541
}
3642

3743
smtc_hal_status_t hal_flash_deinit( void )

lr1110/lr1110/src_changed/smtc_hal_gpio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

2-
#include "smtc_hal_gpio.h"
32
#include "smtc_hal_config.h"
3+
#include "smtc_hal_gpio.h"
4+
#include "smtc_hal_mcu.h"
45

56
#include <libtock/net/lora_phy.h>
67
#include <libtock/peripherals/gpio.h>

lr1110/lr1110/src_changed/smtc_hal_mcu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#include "smtc_hal_rtc.h"
44

55
#include <stdarg.h>
6-
#include <string.h>
76
#include <stdio.h>
7+
#include <stdlib.h>
8+
#include <string.h>
89

10+
#include <libtock-sync/services/alarm.h>
911

1012
void hal_clock_init(void)
1113
{
@@ -57,7 +59,7 @@ void hal_hex_to_bin( char *input, uint8_t *dst, int len )
5759
{
5860
char tmp[3];
5961
uint16_t length = strlen( input );
60-
tmp[2] = NULL;
62+
tmp[2] = '\0';
6163
for( int i = 0; i < length; i+=2 )
6264
{
6365
tmp[0] = input[i];

lr1110/lr1110/src_changed/smtc_hal_rtc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "smtc_hal_rtc.h"
33

44
#include <libtock/peripherals/syscalls/alarm_syscalls.h>
5+
#include <libtock-sync/services/alarm.h>
56

67

78
uint32_t hal_rtc_get_time_s( void )

0 commit comments

Comments
 (0)