Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for 1m flash #1534

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
branch = master
[submodule "sdk/OpenBL602"]
path = sdk/OpenBL602
url = https://github.com/openshwprojects/OpenBL602.git
url = https://github.com/giedriuslt/OpenBL602.git
branch = master
[submodule "sdk/OpenW800"]
path = sdk/OpenW800
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ sdk/OpenXR809/project/oxr_sharedApp/shared:
ln -s "$(shell pwd)/" "sdk/OpenXR809/project/oxr_sharedApp/shared"

sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared:
#cannot symlink shared directly, because sdk is looking for stuff recursively and crashes
#so only linking source and copying required file
@echo mkdir shared
mkdir sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
cp ./bouffalo.mk sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
@echo Create symlink for $(APP_NAME) into sdk folder
ln -s "$(shell pwd)/" "sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared"
ln -s "$(shell pwd)/src/" "sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared/src"

sdk/OpenW800/sharedAppContainer/sharedApp:
@echo Create symlink for $(APP_NAME) into sdk folder
Expand Down
2 changes: 1 addition & 1 deletion sdk/OpenBL602
4 changes: 2 additions & 2 deletions src/cmnds/cmd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ static commandResult_t CMD_PowerSave(const void* context, const char* cmd, const
}
#elif defined(PLATFORM_BL602)
if (bOn) {
wifi_mgmr_sta_powersaving(2);
wifi_mgmr_sta_ps_enter(2);
}
else {
wifi_mgmr_sta_powersaving(0);
wifi_mgmr_sta_ps_exit();
}
#elif defined(PLATFORM_LN882H)
// this will be applied after WiFi connect
Expand Down
4 changes: 2 additions & 2 deletions src/driver/drv_bl0937.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#elif PLATFORM_BL602

#include "../../../../../../components/hal_drv/bl602_hal/hal_gpio.h"
#include "../../../../../../components/hal_drv/bl602_hal/bl_gpio.h"
#include "hal_gpio.h"
#include "bl_gpio.h"

#elif PLATFORM_LN882H

Expand Down
70 changes: 4 additions & 66 deletions src/hal/bl602/hal_uart_bl602.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,10 @@

#include "../hal_uart.h"
#include <vfs.h>
#include <bl_uart.h>
#include <bl_irq.h>
#include <event_device.h>
#include <cli.h>
#include <aos/kernel.h>
#include <aos/yloop.h>

#include <FreeRTOS.h>
#include <task.h>
#include <timers.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

#include <vfs.h>
#include <aos/kernel.h>
#include <aos/yloop.h>
#include <event_device.h>
#include <cli.h>

#include <lwip/tcpip.h>
#include <lwip/sockets.h>
#include <lwip/netdb.h>
#include <lwip/tcp.h>
#include <lwip/err.h>
#include <http_client.h>
#include <netutils/netutils.h>

#include <bl602_glb.h>
#include <bl602_hbn.h>

#include <bl_uart.h>
#include <bl_chip.h>
#include <bl_wifi.h>
#include <hal_wifi.h>
#include <bl_sec.h>
#include <bl_cks.h>
#include <bl_irq.h>
#include <bl_dma.h>
#include <bl_timer.h>
#include <bl_gpio_cli.h>
#include <bl_wdt_cli.h>
#include <hal_uart.h>
#include <hal_sys.h>
#include <hal_gpio.h>
#include <hal_boot2.h>
#include <hal_board.h>
#include <looprt.h>
#include <loopset.h>
#include <sntp.h>
#include <bl_sys_time.h>
#include <bl_sys.h>
#include <bl_sys_ota.h>
#include <bl_romfs.h>
#include <fdt.h>
#include <device/vfs_uart.h>
#include <utils_log.h>
#include <bl_uart.h>
#include <bl602_uart.h>

#include <easyflash.h>
#include <bl60x_fw_api.h>
#include <wifi_mgmr_ext.h>
#include <utils_log.h>
#include <libfdt.h>
#include <blog.h>
#include <aos/yloop.h>

//int g_fd;
uint8_t g_id = 1;
Expand Down Expand Up @@ -151,13 +90,12 @@ int HAL_UART_Init(int baud, int parity)
if(fd_console >= 0)
{
aos_ioctl(fd_console, IOCTL_UART_IOC_BAUD_MODE, baud);
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "Init CLI with event Driven\r\n");
aos_cli_init(0);
aos_poll_read_fd(fd_console, console_cb_read, (void*)0x12345678);
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "UART init done\r\n");
}
else
{
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "failed CLI with event Driven\r\n");
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "UART init failed\r\n");
}
}
return 1;
Expand Down
7 changes: 3 additions & 4 deletions src/hal/bl602/hal_wifi_bl602.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
#include "../hal_wifi.h"
#include "../../new_common.h"
#include "../../new_cfg.h"

#include <string.h>
#include <cli.h>

#include <FreeRTOS.h>
#include <task.h>
#include <portable.h>
Expand Down Expand Up @@ -34,7 +31,9 @@ void HAL_ConnectToWiFi(const char *ssid, const char *psk, obkStaticIP_t *ip)
}
wifi_interface = wifi_mgmr_sta_enable();

wifi_mgmr_sta_connect(wifi_interface, ssid, psk, NULL, NULL, 0, 0);
// sending WIFI_CONNECT_PMF_CAPABLE is crucial here, without it, wpa3 or wpa2/3 mixed mode does not work and
// connection is unstable, mqtt disconnects every few minutes
wifi_mgmr_sta_connect_mid(wifi_interface, ssid, psk, NULL, NULL, 0, 0, ip->localIPAddr[0] == 0 ?1:0, WIFI_CONNECT_PMF_CAPABLE);

g_bAccessPointMode = 0;
}
Expand Down
16 changes: 0 additions & 16 deletions src/httpserver/rest_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,8 @@ uint32_t flash_read(uint32_t flash, uint32_t addr, void* buf, uint32_t size);
#define FLASH_INDEX_XR809 0

#elif PLATFORM_BL602
#include <stdio.h>
#include <string.h>

#include <FreeRTOS.h>
#include <task.h>
#include <lwip/mem.h>
#include <lwip/memp.h>
#include <lwip/dhcp.h>
#include <lwip/tcpip.h>
#include <lwip/ip_addr.h>
#include <lwip/sockets.h>
#include <lwip/netdb.h>

#include <cli.h>
#include <hal_boot2.h>
#include <hal_sys.h>
#include <utils_sha256.h>
#include <bl_sys_ota.h>
#include <bl_mtd.h>
#include <bl_flash.h>
#elif PLATFORM_W600
Expand Down
3 changes: 1 addition & 2 deletions src/new_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ int strcpy_safe(char *tg, const char *src, int tgMaxLen);
int strcpy_safe_checkForChanges(char *tg, const char *src, int tgMaxLen);
void urldecode2_safe(char *dst, const char *srcin, int maxDstLen);
int strIsInteger(const char *s);

#if !defined(PLATFORM_ESPIDF) && !defined(PLATFORM_TR6260)
#if !defined(PLATFORM_ESPIDF) && !defined(PLATFORM_TR6260) && !defined(PLATFORM_BL602)
const char* strcasestr(const char* str1, const char* str2);
#endif

Expand Down
59 changes: 4 additions & 55 deletions src/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
void bg_register_irda_check_func(FUNCPTR func);
#elif PLATFORM_BL602
#include <bl_sys.h>
#include <bl_adc.h> // For BL602 ADC HAL
#include <bl602_adc.h> // For BL602 ADC Standard Driver
#include <bl602_glb.h> // For BL602 Global Register Standard Driver
#include <hosal_adc.h>
#include <bl_wdt.h>
#elif PLATFORM_W600 || PLATFORM_W800
#include "wm_watchdog.h"
Expand Down Expand Up @@ -114,59 +112,10 @@ static int get_tsen_adc(
float *temp, // Pointer to float to store the temperature
uint8_t log_flag // 0 to disable logging, 1 to enable logging
) {
static uint16_t tsen_offset = 0xFFFF;
float val = 0.0;

// If the offset has not been fetched...
if (0xFFFF == tsen_offset) {
// Define the ADC configuration
tsen_offset = 0;
ADC_CFG_Type adcCfg = {
.v18Sel = ADC_V18_SEL_1P82V, /*!< ADC 1.8V select */
.v11Sel = ADC_V11_SEL_1P1V, /*!< ADC 1.1V select */
.clkDiv = ADC_CLK_DIV_32, /*!< Clock divider */
.gain1 = ADC_PGA_GAIN_1, /*!< PGA gain 1 */
.gain2 = ADC_PGA_GAIN_1, /*!< PGA gain 2 */
.chopMode = ADC_CHOP_MOD_AZ_PGA_ON, /*!< ADC chop mode select */
.biasSel = ADC_BIAS_SEL_MAIN_BANDGAP, /*!< ADC current form main bandgap or aon bandgap */
.vcm = ADC_PGA_VCM_1V, /*!< ADC VCM value */
.vref = ADC_VREF_2V, /*!< ADC voltage reference */
.inputMode = ADC_INPUT_SINGLE_END, /*!< ADC input signal type */
.resWidth = ADC_DATA_WIDTH_16_WITH_256_AVERAGE, /*!< ADC resolution and oversample rate */
.offsetCalibEn = 0, /*!< Offset calibration enable */
.offsetCalibVal = 0, /*!< Offset calibration value */
};
ADC_FIFO_Cfg_Type adcFifoCfg = {
.fifoThreshold = ADC_FIFO_THRESHOLD_1,
.dmaEn = DISABLE,
};

// Enable and reset the ADC
GLB_Set_ADC_CLK(ENABLE, GLB_ADC_CLK_96M, 7);
ADC_Disable();
ADC_Enable();
ADC_Reset();

// Configure the ADC and Internal Temperature Sensor
ADC_Init(&adcCfg);
ADC_Channel_Config(ADC_CHAN_TSEN_P, ADC_CHAN_GND, 0);
ADC_Tsen_Init(ADC_TSEN_MOD_INTERNAL_DIODE);
ADC_FIFO_Cfg(&adcFifoCfg);

// Fetch the offset
BL_Err_Type rc = ADC_Trim_TSEN(&tsen_offset);

// Must wait 100 milliseconds or returned temperature will be negative
rtos_delay_milliseconds(100);
}
// Read the temperature based on the offset
val = TSEN_Get_Temp(tsen_offset);
if (log_flag) {
printf("offset = %d\r\n", tsen_offset);
printf("temperature = %f Celsius\r\n", val);
}


// Return the temperature
*temp = val;
*temp = hosal_adc_tsen_value_get_f(hosal_adc_device_get());
return 0;
}
#endif
Expand Down
Loading