Skip to content

Commit

Permalink
Merge branch 'Ralim:dev' into Off=>Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
discip authored Aug 3, 2023
2 parents 4e88089 + 2d7abc2 commit 679bf0c
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 18 deletions.
99 changes: 99 additions & 0 deletions Documentation/Bluetooth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Bluetooth Low Energy

The Pinecilv2 has hardware support for Bluetooth Low Energy (BLE). This protocol allows reading and writing of parameters to the Pinecil during runtime.

The BLE interface advertises three services, these provide access to live telemetry as well as the ability to read/write settings.
These are outlined in more detail below.

Pinecil devices advertise themselves on BLE as `Pinecil-XXXXXXX`.
They also include the UUID `9eae1000-9d0d-48c5-AA55-33e27f9bc533` in the advertisement packet to allow for filtering.

Unless otherwise noted, all data is sent and received as Little-Endian.

As of the time of writing this, notifications are not fully implemented so data will need to be polled. Notification/Indication support will come when there is time to implement it.

## Using the BLE Interface

It is advised to follow the below points when first implementing a BLE integration. Of course once the integration is working feel free to deviate from these. These are just _suggested_ ideas to help kickstart.

1. When filtering for devices, its preferable to filter by the UUID `9eae1000-9d0d-48c5-AA55-33e27f9bc533`, rather than by the device name if possible.
2. Upon first collection check if the three expected services exist; if they don't the user may have selected an incorrect device.
3. It's best to read the live bulk endpoint over the live service when its easy to do so (one read vs ~15).
1. However if you are just updating one or two line items it may be more efficient to just read these on the live service.
2. Feel free to test both and decide.
4. When reading settings from the device; the association of number <-> setting is fixed, but you may see settings you don't yet know about, make sure you can handle these.
5. You probably don't want to show unknown setting's to the user though.
6. Read the device firmware revision and ensure you can decode it. If BLE is revised it may be essential for handling versions cleanly.
7. It's advisable to keep an eye on the IronOS repository or at least setup the Github watch for release notifications.
1. Future releases may revise some BLE aspects or add new settings for example.

## Services

Below is a description of each service. Note that the exact settings are not listed for brevity; it's best to refer to [the uuid lists](https://github.com/Ralim/IronOS/blob/dev/source/Core/BSP/Pinecilv2/ble_characteristics.h) and the [handlers](https://github.com/Ralim/IronOS/blob/dev/source/Core/BSP/Pinecilv2/ble_handlers.cpp) alongside this.

### Live

`UUID: d85ef000-168e-4a71-AA55-33e27f9bc533`

The live services has one characteristic per reading. The readings (in order) are:
When implementing these; the ones that are not obvious are generally found in the debugging menu. Values are encoded as an unsigned 32 bit number for all results.

1. Live temperature (In C)
2. Live set point
3. DC input voltage
4. Handle temperature (In C)
5. Power level
6. Power source
7. Tip resistance
8. uptime
9. Time of last movement
10. Maximum temperature settable
11. Raw tip reading
12. Hall sensor
13. Operating mode
14. Estimated wattage

### Settings

`UUID: f6d80000-5a10-4eba-AA55-33e27f9bc533`

The settings service has two special entries; for saving and resetting settings.
Otherwise all settings are enumerated using UUID's of the format : `f6d7ZZZZ-5a10-4eba-AA55-33e27f9bc533))` where `ZZZZ` is the setting number as matched from [Settings.h](https://github.com/Ralim/IronOS/blob/dev/source/Core/Inc/Settings.h#L16).

All data is read and written in fixed unsigned 16 bit numbers.

#### Settings save

To save the settings write a `0x0001` to `f6d7FFFF-5a10-4eba-AA55-33e27f9bc533`.
Its advised to not save settings on each change but instead to give the user a save button _or_ save after a timeout. This is just to reduce write cycles on the internal flash.

#### Settings reset

To reset all settings to defaults; write a `0x0001` to `f6d7FFFE-5a10-4eba-AA55-33e27f9bc533`.
This will reset settings immediately.

### Bulk

`UUID: 9eae1000-9d0d-48c5-AA55-33e27f9bc533`

The bulk endpoint is where extra data is located with varying read sizes.

#### Live data

The bulk live data endpoint provides all of the data provided in the live endpoint, as one large single-read binary blob. This is designed for applications that are showing large amounts of data as this is more efficient for reading.

#### Accelerometer Name

_Not yet implemented_

#### Build ID

This encodes the current build ID to allow viewing and handling when the BLE format changes.

#### Device Serial Number

This is generally the device CPU serial number. For most devices this can be used as an ID. On PinecilV2 its the MAC address.

#### Device Unique ID

This is only relevant on the PinecilV2. This is a random ID that is burned in at the factory. This is used by the online authenticity checker tool.
12 changes: 12 additions & 0 deletions Documentation/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ But it is helpful to do some basic diagnostics first just in case the issue is e
The **VAST** majority of issues are poor soldering or cold solder joints.
If you can open up your iron, give it a good look at all the connection points, and use another iron to reflow any suspicious ones, this can fix most issues.

## Tip Shorted warning

If you are powering up a device that supports tip resistance detection (TS101 and Pinecilv2 as of present), the firmware checks the readings of the raw tip resistance and sorts these into three "bins". `8 ohm tips`, `6.2 ohm tips` and `tip-shorted`. The tip resistance is used when negotiating USB-PD and in thermal calculations.
The `tip-shorted` option is selected if your tip is measured to be abnormally small. This could indicate a failed driver mosfet or a failed tip.

When this warning is shown; heating will be disabled to protect from damage. As trying to heat a shorted tip can damage the iron itself.

It is best to take out your tip and manually measure and verify the tip's resistance. It should be 6-8 ohms (depending on tip type). When measuring resistances this small some multimeters can struggle. If you have access to a current limited bench power supply, you can try doing a 4 wire measurement by measuring the voltage drop on the tip while applying a known current. `(R=V/I)`.

If the tip measures correctly you may have a damaged driver mosfet; it would be ideal to open your iron and test the mosfet is operating correctly.
If after both of these checks everything looks as expected, feel free to open a discussion on IronOS to talk about the issue (Or for Pinecil the community chat can be a much faster response).

## High tip temp reading when the tip is cool

If you are finding the tip is reading high; the first fields to check in the Debug menu are `RTip` and `CHan`.
Expand Down
Empty file modified Translations/translation_JA_JP.json
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions source/Core/BSP/BSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ void setBuzzer(bool on);
// For example, on the MHP30 this is used to figure out the resistance of the hotplate
uint8_t preStartChecks();
uint8_t preStartChecksDone();

// Show the boot logo
void showBootLogo(void);
#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 4 additions & 1 deletion source/Core/BSP/MHP30/BSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BSP mapping functions

#include "BSP.h"
#include "BootLogo.h"
#include "I2C_Wrapper.hpp"
#include "Pins.h"
#include "Setup.h"
Expand Down Expand Up @@ -472,4 +473,6 @@ uint64_t getDeviceID() {
uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }

void showBootLogo(void) { BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); }
4 changes: 2 additions & 2 deletions source/Core/BSP/MHP30/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@
#define HARDWARE_MAX_WATTAGE_X10 650
#define TIP_THERMAL_MASS 65 // TODO, needs refinement
#define TIP_RESISTANCE 60 // x10 ohms, ~6 typical
#endif /* MHP30 */
#endif /* MHP30 */

#ifdef ACCEL_EXITS_ON_MOVEMENT
#define NO_SLEEP_MODE
#endif

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

#endif /* CONFIGURATION_H_ */
5 changes: 4 additions & 1 deletion source/Core/BSP/Miniware/BSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BSP mapping functions

#include "BSP.h"
#include "BootLogo.h"
#include "I2C_Wrapper.hpp"
#include "Pins.h"
#include "Setup.h"
Expand Down Expand Up @@ -407,4 +408,6 @@ uint8_t getTipInertia() {
#else
return TIP_THERMAL_MASS;
#endif
}
}

void showBootLogo(void) { BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); }
5 changes: 4 additions & 1 deletion source/Core/BSP/Pinecil/BSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BSP mapping functions

#include "BSP.h"
#include "BootLogo.h"
#include "I2C_Wrapper.hpp"
#include "IRQ.h"
#include "Pins.h"
Expand Down Expand Up @@ -97,4 +98,6 @@ uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
uint8_t preStartChecksDone() { return 1; }

uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_MASS; }

void showBootLogo(void) { BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); }
11 changes: 10 additions & 1 deletion source/Core/BSP/Pinecilv2/BSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BSP mapping functions

#include "BSP.h"
#include "BootLogo.h"
#include "I2C_Wrapper.hpp"
#include "IRQ.h"
#include "Pins.h"
Expand All @@ -10,6 +11,7 @@
#include "Utils.h"
#include "configuration.h"
#include "crc32.h"
#include "hal_flash.h"
#include "history.hpp"
#include "main.hpp"

Expand Down Expand Up @@ -278,4 +280,11 @@ uint8_t getDeviceValidationStatus() {
uint32_t programmedHash = EF_Ctrl_Get_Key_Slot_w1();
uint32_t computedHash = gethash();
return programmedHash == computedHash ? 0 : 1;
}
}

void showBootLogo(void) {
uint8_t scratch[1024];
flash_read(FLASH_LOGOADDR - 0x23000000, scratch, 1024);

BootLogo::handleShowingLogo(scratch);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ __EM_SIZE =8K;

MEMORY
{
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1022K
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1008K /*1024 - 8K header - 4K*2 for settings and logo*/
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 12K
dtcm_memory (rx) : ORIGIN = 0x42014000, LENGTH = 8K
ram_memory (!rx) : ORIGIN = 0x42016000, LENGTH = 72K
Expand Down
16 changes: 9 additions & 7 deletions source/Core/BSP/Pinecilv2/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
* OLED Brightness
*
*/
#define MIN_BRIGHTNESS 1 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 101 // Max OLED brightness selectable
#define BRIGHTNESS_STEP 25 // OLED brightness increment
#define DEFAULT_BRIGHTNESS 26 // default OLED brightness
#define MIN_BRIGHTNESS 1 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 101 // Max OLED brightness selectable
#define BRIGHTNESS_STEP 25 // OLED brightness increment
#define DEFAULT_BRIGHTNESS 26 // default OLED brightness

/**
* Temp change settings
Expand All @@ -87,7 +87,7 @@
#define POWER_PULSE_DEFAULT 0
#else
#define POWER_PULSE_DEFAULT 5
#endif /* Pinecil */
#endif /* Pinecil */
#define POWER_PULSE_WAIT_DEFAULT 4 // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s
#define POWER_PULSE_DURATION_DEFAULT 1 // Default duration of the power pulse: 1*250 = 250 ms

Expand Down Expand Up @@ -167,8 +167,10 @@
#define CANT_DIRECT_READ_SETTINGS
#endif /* Pinecilv2 */

#define FLASH_LOGOADDR (0x23000000 + (1022 * 1024))
#define FLASH_PAGE_SIZE (1024)
#define FLASH_PAGE_SIZE (1024) // Read pages
// Erase is 4 or 8 k size, so we pad these apart for now
// If we ever get low on flash, will need better solution
#define FLASH_LOGOADDR (0x23000000 + (1016 * FLASH_PAGE_SIZE))
#define SETTINGS_START_PAGE (1023 * FLASH_PAGE_SIZE) // Hal auto offsets base addr

#endif /* CONFIGURATION_H_ */
5 changes: 4 additions & 1 deletion source/Core/BSP/Sequre_S60/BSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BSP mapping functions

#include "BSP.h"
#include "BootLogo.h"
#include "HUB238.hpp"
#include "I2C_Wrapper.hpp"
#include "Pins.h"
Expand Down Expand Up @@ -236,4 +237,6 @@ uint8_t preStartChecksDone() { return 1; }
uint8_t getTipThermalMass() { return TIP_THERMAL_MASS; }
uint8_t getTipInertia() { return TIP_THERMAL_INERTIA; }

void setBuzzer(bool on) {}
void setBuzzer(bool on) {}

void showBootLogo(void) { BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); }
3 changes: 1 addition & 2 deletions source/Core/Threads/GUIThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void startGUITask(void const *argument) {
currentTempTargetDegC = min(sleepTempDegC, 75);
}

BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR);

showBootLogo();
showWarnings();
if (getSettingValue(SettingsOptions::AutoStartMode)) {
// jump directly to the autostart mode
Expand Down
3 changes: 2 additions & 1 deletion source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ DEVICE_BSP_DIR=./Core/BSP/Pinecilv2
S_SRCS:=$(shell find $(PINECILV2_DIR) -type d \( -path $(PINECILV2_VENDOR_BSP_COMMON_DIR) \) -prune -false -o -type f -name '*.S') $(info $(S_SRCS) )
ASM_INC=$(DEVICE_INCLUDES)
LDSCRIPT=./Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/bl702_flash.ld

DEVICE_DFU_ADDRESS=0x23000000
# DFU starts at the beginning of flash
# Flags
CPUFLAGS=-march=rv32imafc \
-mabi=ilp32f \
Expand Down

0 comments on commit 679bf0c

Please sign in to comment.