Sinapse-Energia / talking-fiber

Firmware for optic fiber activity detection. Based on M3 MCU
0 stars 1 forks source link

Refactor Bootloader #2

Open ralcaide opened 6 years ago

ralcaide commented 6 years ago

Like in #1. Is necessary to modify the GPIO init and delete the unnecessary transceivers.

ralcaide commented 6 years ago

This modification should be done in other repository. TODO RAE: Point here the repo / branch to be modified

ralcaide commented 6 years ago

Branch for talking fiber bootloader:

https://github.com/Sinapse-Energia/bootloader-stm32/tree/CortexM3_TalkingFiber

TODO:

ralcaide commented 6 years ago

Please, perform this task in order to close the MVP

vAnArhist commented 6 years ago

We are getting HardFault() when testing on GPRS connect stage.

ralcaide commented 6 years ago

I saw the code and I don't understand very well how are you managing the new DEFAULTBOARD tag named TFiberBoard. You define it but then is not used, right? This BL should be compatible with all the Sinapse M3 boards, depending the board is necessary to call a different GPIO_INIT and maybe do some extra operations. Is maybe this HF related with the bad management of the board?

ghost commented 6 years ago

As I see in commit, the board management is also done in GPIO init, by checking board type and performing specific init for TF board.

ralcaide commented 6 years ago

Right, sorry. So, any idea about the HF?

vAnArhist commented 6 years ago

HF appears in M95 driver while connecting. In Tranceiver.cpp line 479 there is call for executeCommand executeCommand(&trerror, phuart, 0); In this call cirular buffer pointer is 0, so when executeCommand try to access circular buffer (Tranceiver.cpp line 356) it passes zero pointer to Stock function, Stock try to access circular buffer on this pointer and goes to HF because access zero pointer. This bug appears only when execute command call in line 477 returns zero (when some AT command request getting invalid response from M95). Proposed fix: add zero pointer check into Stock or executeCommand functions.

ralcaide commented 6 years ago

Thanks, I will explain that to the Engine Developer and will come back with a proposed solution

ralcaide commented 6 years ago

Questions:

ralcaide commented 6 years ago

After take a look to the code we've found the problem. We will have the fix this night and I will add here the patch. Leave in standby this task until then

ralcaide commented 6 years ago

Please, integrate the last two commits (5 sept) of this branch https://github.com/Sinapse-Energia/bootloader-stm32/commits/CortexM3 in order to fix the problem:

  1. This should fix the problem: https://github.com/Sinapse-Energia/bootloader-stm32/commit/fc16ca94e5c668718308da7250d065933a679d4b

  2. This avoid failures of QIOPEN: https://github.com/Sinapse-Energia/bootloader-stm32/commit/ef984dc2f215e4ba939d778f6548c2e0eb6c77ec

vAnArhist commented 6 years ago

Commits integrated, bootloader tested and working.

ralcaide commented 5 years ago

This issue should be tested. Until now we were working without BL

ralcaide commented 5 years ago

We are now testing the Bootloader integration with the current client and it is not working. The definitions of the Bootloader that we are using is the following one. @vAnArhist , could you please test why is not working in one of your devices? The binary is in our server. Try to download this binary and check the the BL launch the client and if not try to understand why, please.

`#ifndef _DEFINITIONSH

define _DEFINITIONSH

define DEBUG

define BOOTLOADER

// Value to be used when discovery fails // Values are: // Board0 -> Classic M2M (Vodafone) // Board1 -> Square, piggyback M2M // Board2 -> Pretty box (Orange) //#define DEFAULTBOARD Board1

define DEFAULTBOARD TFiberBoard

// LABELS for SELECTIVE BUILD

// LABELS FOR TRANSCEIVERS

define BUILD_M95

//#define BUILD_BG96 //#define BUILD_RM08

if defined(BUILD_ALL)

#define BUILD_M95
#define BUILD_BG96
#define BUILD_RM08
#define BUILD_CANBUS

endif

// TRASPORT LABEL (COMPOSITES)

if defined(BUILD_M95) || defined(BUILD_BG96)

define GPRS_TRANSPORT

define DEFAULTBOARD TFiberBoard

endif

if defined(BUILD_RM08)

define ETH_TRANSPORT

endif

// LABELS FOR OPTIONAL FEATURES

undef BUILD_RTC

undef BUILD_DMA

undef BUILD_TLS

undef BUILD_NONTRANSPARENTMODE

ifdef __cplusplus

extern "C" {

endif

// // // // // *** //

// RAE definitions

define COMMUNICATION_M95

// Francis definition.

define CMC_APPLICATION_DEPENDENT

define LOG_WIFI 1

define NUMBER_RETRIES 1

// seconds after submit HLK configuration

define TIME_HLKCONFIG 10 // In seconds

// seconds after submit HLK connection

define TIME_HLKCONNECT 50 // In seconds

// GPRS init

define SIZE_APN 60

define SIZE_MAIN_SERVER 60

define SIZE_NTP_SERVER 60

define SIZE_GPRS_BUFFER 256

define TIMING_TIMEOUT_GPRS 20

//#define const_APN "\"im2m.matooma.com\",\"movistar\",\"movistar\"\r\0" //#define const_APN "\"m2m.tele2.com\",\"tele2\",\"tele2\"\r\0"

define const_APN "\"TM\",\"\",\"\"\0"

//#define const_APN "\"lte.m2m\",\"\",\"\"\0" //#define const_APN "\"orangeworld\",\"orange\",\"orange\"\r\0"

define const_SERVER_NTP "\"0.europe.pool.ntp.org\"\r\0"

//#define const_MAIN_SERVER "\"m2m.eclipse.org\",1883\r\0" //#define const_MAIN_SERVER "\"178.94.164.124\",80\r\0" //#define const_MAIN_SERVER "\"89.248.100.11\",80\r\0" //#define const_MAIN_SERVER "\"sinapseenergia.com\",80\r\0" //#define const_MAIN_SERVER "\"sinapseenergia.com\"\r\0"

// Maximum number ot connection tries before resetting the device

define MAX_CONNECT_TRIES 5

// Maximum size for the datablock to save & restore from NVM

define STORESIZE 512

define RTC_CLOCK_SOURCE_LSI

//#define RTC_CLOCK_SOURCE_LSE //Se usa el externo 32768Hz. //#define RTC_CLOCK_SOURCE_HSE //Se usa el externo 32768Hz.

ifdef RTC_CLOCK_SOURCE_LSI

define RTC_ASYNCH_PREDIV 0x7F

define RTC_SYNCH_PREDIV 0x137

endif

ifdef RTC_CLOCK_SOURCE_LSE

define RTC_ASYNCH_PREDIV 0x7F

define RTC_SYNCH_PREDIV 0x00FF

endif

ifdef RTC_CLOCK_SOURCE_HSE

define RTC_ASYNCH_PREDIV 100

define RTC_SYNCH_PREDIV 8125

endif

// Wait for HTTP server answer (sec)

define TIMING_TIMEOUT_UART 15

// HTTP connection

//#define HTTP_SERVER_IP "sinapseenergia.com\0"

define HTTP_SERVER_IP "www.eluxoon.com\0"

define HTTP_SERVER_IP_03 89//178

define HTTP_SERVER_IP_02 248//94

define HTTP_SERVER_IP_01 100//164

define HTTP_SERVER_IP_00 11//124

define HTTP_SERVER_PORT 80

define const_string_PORT "80\0"

define const_ID_DEVICE "600012\0"

define const_GPIO "10000000\0"

define const_PWM "100\0"

//#define HTTP_SERVER_FW_FILENAME "600012.bin\0" //#define HTTP_SERVER_FW_FILENAME "TESTING_M2M.bin\0" //#define HTTP_SERVER_FW_FILENAME "EC-M2M-LU_LUM-V114-NODEBUG.bin\0"

// Client using M95 //#define HTTP_SERVER_FW_FILENAME "EC-M2M-LU_LUM-V114-DEBUG.bin\0" // Client using RM08 on board1 (piggy-back) //#define HTTP_SERVER_FW_FILENAME "B1-HLK-WIFI-JR-V1.26.bin" // Client using RM08 on board2 (Orange) // #define HTTP_SERVER_FW_FILENAME "B2-HLK-WIFI-JR-V1.26.bin"

define HTTP_SERVER_FW_FILENAME "talking_fiber_test_TM.bin"

//#define HTTP_SERVER_FW_FILENAME "B0-ALL-ETH-JR-V1.26.3.bin" //#define HTTP_SERVER_FW_FILENAME "B0-ALL-WIFI-JR-V1.26.3.bin"

//define HTTP_SERVER_FW_FILENAME "B1-ALL-WIFI-JR-V1.26.3.bin" //#define HTTP_SERVER_FW_FILENAME "B1-ALL-ETH-JR-V1.26.3.bin"

define const_ROUTE_FW_FILENAME ""

define const_UPDFW_COUNT "1\0"

define const_UPDFW "1\0"

// Define Bank Sectors (11 sectors total - for STM32F4xx devices) // Bootloader /// Verified: Definition sector in STM32F2xx is equivalent to STM32F4xx family.

define ORIGIN_SECTOR ((uint32_t)0x080E0000) / last 128k /

define FLASH_BANKB_START_SECTOR FLASH_SECTOR_0

define FLASH_BANKB_SECTORS 3

// Application

define FLASH_BANKA_START_SECTOR FLASH_SECTOR_3

define FLASH_BANKA_SECTORS 5

// Application copy

define FLASH_BANKC_START_SECTOR FLASH_SECTOR_8

define FLASH_BANKC_SECTORS 3

// App version addressing (+ release data address dd/mm/yy) // placed in first address of the Firmware/Application memory

define APP_VER_ADDR_LOW 0x0190

define APP_VER_ADDR_HIGH 0x0191

define APP_VER_ADDR_DD 0x0192

define APP_VER_ADDR_MM 0x0193

define APP_VER_ADDR_YY 0x0194

ifdef __cplusplus

}

endif

endif`

vAnArhist commented 5 years ago

@ralcaide Could you provide on which topic should I subscribe?

ralcaide commented 5 years ago

The binary has an APN that will not work for you I think because the APN is TM. The goal is to check if the bootloader (with your APN) is able to download the client and boot it. Anyway the client is publishing in the Sinapse broker on the topic: TEST_TFS_BL

vAnArhist commented 5 years ago

@ralcaide Tested with bootloader with your binary and mine with changed APN. With your - download OK, but not published (as the APN is not suitable for my SIM operator). Checked downloading binary with my server, changed APN, all is OK, publishing is working.

ralcaide commented 5 years ago

It is strange because for us is not working.

vAnArhist commented 5 years ago

@ralcaide APN:

define const_APN "\"internet\",\"\",\"\"\0"

Checked without debugger, all is ok.

ralcaide commented 5 years ago

@vAnArhist Uploaded a binary into the eluxoon server:

Server: www.eluxoon.com port: 80 path: / name: tf_test_internet.bin apn: internet topic: TFS_DR_BL broker: soporte-tecnico.bitnamiapp.com

Could you please test that it is well downloaded and launched without programmer? If yes, please provide me the diff of your Bootloader in relation the github code and also a bootloder with APN = #define const_APN ""TM","",""\0" We are not able until now to make the BL work with a client.