Lishui "Open Source Firmware" project / KingMeter 5S

I think I fixed the tablet. I'll try to figure out what's going on with the torque sensor.
 
EBiCS_Firmware-2261029
?! What is that? Please simply post a link to the branch/commit you are working with.

Is it possible to enable automatic offset detection when enabling it in my firmware version?
Sure.

Is there a working program for Android
I'm using this, it works with standard Bluetooth and with BLE, you can look at the live data and log the data to a file for later analysis.

 
Last edited:
I decided not to torment you with stupid questions, but to torment ChatGpt.
Surprisingly, I received a lot of useful information.
 
Here is the latest commit that compiles and runs on my controller.
?! This is very, very old. What is the problem with the latest commit of the new generation branch?! It works flawlessly for me, otherwise I wouldn't have published it without a hint...

1766128389817.png

One strange setting in your main.h:

Code:
#define R_TEMP_PULLUP 3000

have you really connected a NTC and is the pullup 3kOhm really?!

The default value is zero, as most motors have no NTC installed...


The values for the torque offset and torque max are strange also, but may work...
 
Last edited:
I'll now try to use ChatGpt to understand in detail what's going on in the firmware. I'm tired of poking around like a blind kitten. Then I'll measure everything again and check. Then my questions will be more meaningful.

Regarding the old version of the program.

Newer versions either don't compile on my computer or don't run on my controller. I tried all versions. I'll deal with that later.
 
Any thoughts?
Is the linked commit the last one that works, or the first that doesn't work? Which error message is thrown? Do you use the Java Tool for settings and compiling?
Edit; I just tried it with the Java Tool, it compiles without errors:
1766315053963.png
 
Last edited:
Commit 2261029 is the last one to run.

I provided a link to a comparison between commit 2261029 and the following commit, which compiles and loads, but doesn't run on the controller. I'm using the Java Tool.
 
which compiles and loads, but doesn't run on the controller
The next (relevant) commit changes the address of the virtual EEPROM. Have you run the autodetect again after flashing? This is essential, otherwise the hall angles are not available to turn the motor.

Please try it with the latest commit at GitHub.
What says the STM32Utility, when connecting to the processor? It has to be "medium density", if it shows "low density" the processor is not the usual one for the "new generation"

1766331977358.png
 
Last edited:

Here is the result of working with non-human intelligence:

What exactly to change in the project (in practical terms)

1) Macro devices

Right now, your log shows that compilation is running with:



-DSTM32F103xB



For C8, it is more correct to say:



-DSTM32F103x8



And (if available) select the appropriate startup file (not critical, but more accurate):



startup_stm32f103x8.s instead of startup_stm32f103xb.s (if both are present in the project)

2) Linker — you did the right thing.

Your option:



FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0xF800 /* 62KB, до 0x0800F7FF */
EEPROM (rx): ORIGIN = 0x0800F800, LENGTH = 0x800 /* 2KB */


That's exactly "64KB minus 2KB for EEPROM".

3) EEPROM emulation — match addresses with the linker

If the EEPROM is located in the last 2KB (0x0800F800..0x0800FFFF), then eeprom.h should contain:


start EEPROM_START_ADDRESS = ADDR_FLASH_PAGE_62

PAGE0 = page 62 (0x0800F800)

PAGE1 = page 63 (0x0800FC00)



It looks consistent to you now.

Why do you now have "both EE_Init and EE_ReadVariable already starting"?

Because you:

  • stopped hitting EEPROM emulation/code in "dangerous" areas (intersection with the program),
  • and/or removed the conflict with incorrect pages,
  • and the linker finally "forbade" the layout designer from occupying the last 2KB.


So yes, it seems you really did solve the problem architecturally.
 
This is how the last commit 12FET_N_G was launched.
 

Attachments

  • main.c
    72 KB · Views: 0
  • eeprom.h
    15.4 KB · Views: 0
  • STM32F103C8Tx_FLASH.ld.txt
    4.7 KB · Views: 0
The motor is spinning, everything works.
 

Attachments

  • main.c
    72.2 KB · Views: 0
  • main.h
    6.8 KB · Views: 0
I think the problem is that I'm compiling from a downloaded archive and using 128 instead of 64, whereas yours is compiling from an external source, where everything is written correctly. This is my amateur version.
 
Last edited:
using 128 instead of 64,
I'm using 128 and it works flawlessly. But It's known that this pages may be corrupt. There are several reports on that:
STM32F103x8 and STM32F103xB are the same chip. So the 128k flash are on chip. On a STM32F103xB, the upper 64 kB are fully tested, on a a STM32F103x8 the flash is probably not tested or was tested bad. So if you play with a a STM32F103x8, you can try to use the upper flash. But do not rely on that flash to work right!
So may be you have bad luck with your processor. But if it works for you with the virtual EEPROM on pages 62+63 everything is OK(y)
 
Last edited:
I'm probably missing something, but why leave a ticking time bomb in the code if it's so easy to fix for someone who understands what's going on? I should note that I encountered this problem early on and asked why later versions wouldn't run on my controller. The answer is obvious but inaccessible. This should be prominently posted on the wiki or fixed everywhere. Or do you sometimes use more than 64 KB of memory during development, and this "kind of memory overclocking" is really convenient, so you don't have to worry about firmware size every time?
 
leave a ticking time bomb
I've flashed a lot of controllers and many other users too. You are the first who reported issues with the virtual EEPROM on pages 126 and 127.
If we have this issue more often, we should think about shifting it to 62/63, but I guess you simply had bad luck with your processor.🤷‍♂️
 
This should be prominently posted on the wiki or fixed everywhere.

I've flashed a lot of controllers and many other users too. You are the first who reported issues with the virtual EEPROM on pages 126 and 127.
Increasing risks without absolute necessity based on everyday observations and failing to document this danger is beyond me. Well, screw it, let's move on. I'll keep digging.
 
Wait, how quick. I'm currently learning how to use GitHub. So I can commit my code properly. When I get the hang of it and finally get it set up properly, I'll try to make a proper guide or a collection of jokes about what and where to break and tinker with.
 
You said that you managed to implement automatic detection of the torque sensor offset every time the firmware starts. Where can I see this? I want to try adding it to my branch on GitHub.
 
Back
Top