Skip to content

Commit

Permalink
Save settings on change only / All builds OK (#1699) (#1704)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia authored Jun 18, 2023
1 parent 4c5e885 commit 4d7e4f4
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions source/Core/BSP/MHP30/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,4 @@
#endif

#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))
3 changes: 0 additions & 3 deletions source/Core/BSP/MHP30/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#include "stm32f1xx_hal.h"
#include "string.h"

#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))


void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
FLASH_EraseInitTypeDef pEraseInit;
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
Expand Down
1 change: 1 addition & 0 deletions source/Core/BSP/Miniware/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,4 @@
#endif

#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))
2 changes: 0 additions & 2 deletions source/Core/BSP/Miniware/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "stm32f1xx_hal.h"
#include "string.h"

#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))

void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
FLASH_EraseInitTypeDef pEraseInit;
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
Expand Down
1 change: 1 addition & 0 deletions source/Core/BSP/Pinecil/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@
#endif

#define FLASH_LOGOADDR (0x08000000 + (126 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))

#define HAS_POWER_DEBUG_MENU
2 changes: 1 addition & 1 deletion source/Core/BSP/Pinecil/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "gd32vf103_libopt.h"
#include "string.h"
#define FMC_PAGE_SIZE ((uint16_t)0x400U)
#define SETTINGS_START_PAGE (0x08000000 + (127 * 1024))

void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {

/* unlock the flash program/erase controller */
Expand Down
2 changes: 2 additions & 0 deletions source/Core/BSP/Pinecilv2/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@
#endif

#define FLASH_LOGOADDR (0x23000000 + (1022 * 1024))
#define FLASH_PAGE_SIZE (1024)
#define SETTINGS_START_PAGE (1023 * FLASH_PAGE_SIZE) // Hal auto offsets base addr
4 changes: 0 additions & 4 deletions source/Core/BSP/Pinecilv2/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include "hal_flash.h"
#include "string.h"

#define FLASH_PAGE_SIZE (1024)

#define SETTINGS_START_PAGE (1023 * FLASH_PAGE_SIZE) // Hal auto offsets base addr

void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
BL_Err_Type err = flash_erase(SETTINGS_START_PAGE, FLASH_PAGE_SIZE);
err = flash_write(SETTINGS_START_PAGE, buffer, length);
Expand Down
1 change: 1 addition & 0 deletions source/Core/BSP/Sequre_S60/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@
#endif

#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))
2 changes: 0 additions & 2 deletions source/Core/BSP/Sequre_S60/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "stm32f1xx_hal.h"
#include "string.h"

#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))

void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
FLASH_EraseInitTypeDef pEraseInit;
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
Expand Down
6 changes: 5 additions & 1 deletion source/Core/Src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
};
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));

void saveSettings() { flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType)); }
void saveSettings() {
if (memcmp((void *)SETTINGS_START_PAGE, (void *)&systemSettings, sizeof(systemSettingsType))) {
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
}
}

bool loadSettings() {
// We read the flash
Expand Down

6 comments on commit 4d7e4f4

@discip
Copy link
Collaborator

@discip discip commented on 4d7e4f4 Jun 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ralim
@ia
After this commit Pinecil-V2:

  1. not possible to reset to defaults.
  2. when reaching last entry language: OLED freezes. Only unplugging power allowes to leave the menu. Even if language is changed, it cannot be saved.

@ia
Copy link
Collaborator Author

@ia ia commented on 4d7e4f4 Jun 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello.

  • I'm terribly sorry for this problem... and if I would have access to dev, then I would just revert these changes for the further investigation & more deep testing & debugging so not to have dev so broken.
  • I'm ready to take full responsibility for the problem with settings (factory reset/language switch).
  • As of for screen problem... is there any chance it may relate to recent updates for OLED?
  • Anyway, as a quickiest & dirtiest fix I could try to suggest [to flash & test] something like this.
  • FYI unfortunately I will be fully AFK for the next 12 hours at least.
  • Sorry again.

@ia
Copy link
Collaborator Author

@ia ia commented on 4d7e4f4 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-builts with quick&dirty patch just in case for convenience.

@Ralim
Copy link
Owner

@Ralim Ralim commented on 4d7e4f4 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now on dev 🀞🏼

@discip
Copy link
Collaborator

@discip discip commented on 4d7e4f4 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ia
I didn't mean to blame you, I wanted to report this issue at the point of origin so that it can be fixed as soon as possible. 😊

@Ralim

This is fixed now! πŸ‘πŸ»

@ia
Copy link
Collaborator Author

@ia ia commented on 4d7e4f4 Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean to blame you

No-no, I didn't say nor imply that you did, I just try to be honest & responsible with my commits whether it's proprietary software or FOSS project ;)

Please sign in to comment.