Инструкция Bip | Application develop for BipOS ( SDK ) EN

MNVolkov

Разработчик
Команда форума
Сообщения
417
Реакции
2,803
Баллы
483
Ваше "умное" устройство
Amazfit Bip
  • Первое сообщение
  • #1
Application develop for BipOS
Software Development Kit (SDK)

for MNVolkov BipOS

Intro
From version MNVolkov BipOS 0.5 the startup code of the applications is completely redisigned. Each application now is a separate file stored in resources. The executable file format is Arm-elf (or simply"elf"). The mod got a new name BipOS. When the MOD starts, resources are scanned for applications. Each firmware has a different amount of resources, and applications are always placed at the end. Therefore, the loader looks for resources by Elf signature starting with resource 930. Found applications are placed in the menu "Applications".
In order to improve overall convenience and reduce the number of incompatibilities designed firmware independent applications. So one and the same Calculator will work both on Latin 1.1.5.12 and not latin 1.1.2.05 with no changes (you only need to place it in the RES file of the corresponding version). Independence from the firmware managed through using of a universal library libbip.a which contains the addresses of the firmware functions. After loading the elf into RAM, the internal addresses of functions and variables are relocated, and library addresses of functions are changed to real addresses of functions in firmware.

Development environment
To develop applications, you will need a development environment and a compiler. As a development environment I use Notepad++ . Probably, you can configure Code:: Blocks or other IDE I did not get to this, postponed for the future. Installing a specialized IDE will certainly increase the usability of development. I will not dwell on the development environment.

Compiler
I use the GNU Embedded Toolchain for Arm to build the application. The following steps are required for installation:

  1. Download toolchain here:

    Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.


    Download the file gcc-arm-none-eabi-8-2019-q3-update-win32-sha2.exe ( or a more recent edition) with the following description: Windows 32-bit Installer (Signed for Windows 7 and later)
  2. You can set everything by default, at the end of the installation, set all the checkboxes
  3. It is recommend that you add to system PATH variable the path to the compiler bin folder
Library
The library includes both addresses of firmware functions and some functions that are written to facilitate the development of user applications, such as menu functions. The library must be unzipped to a folder at the same level as the application folders. The path to this folder will be specified in the build script.
У вас нет разрешения на просмотр содержимого!

Sample application
Specifically to facilitate the entry of prepared a sample application in C template_app. The functionality is simple: a working screen of the application is created, when you click in the center of the screen, the background color and labels are change.
You can use this example as a template. To do this, create a new application folder and copy the sample files to it. The name of the application folder in the build script is taken as the service name of the application.
The name displayed in the list of applications must be entered in the label.txt in this case after the name should not be any characters or line feed.
To build the application use .bat file. The build is starting by running the .bat file inside the folder without parameters. All compiler and linker parameters compatible with the BipOS loader are included in this script.
Sample application (with RU comments)
У вас нет разрешения на просмотр содержимого!

Sample application (with EN comments - thanx @Bugmenot1 )
У вас нет разрешения на просмотр содержимого!

Sources on GitHub

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.



Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.



Description of App lifecycle
Translate from Russian by @CennoxX - Инструкция - Bip | Application develop for BipOS ( SDK ) EN

Build RES file and load into clock
To run the elf you need to load it in device. To do this, you need to put it in a RES file. To build RES files was developed a special program for PC (Win32) with which you can add to your existing RES file required applications. ResPack.exe is a console application to perform simple operations RES files Amazfit Bip: display content with brief information for each resource, unpacking raw data of resources, making alignment string resources version 61 and 69 to solve the disappearance of text when loading a custom resource and add any files to the resources.
To add application files to an existing RES file run from the command line:
Code:
Код:
ResPack -a <resulting_RES> <source_RES> <files which should be added>
Resulting RES file can be flashed by usual way, for example, with GadgetBridge. To update the data in memory, the clock must be restarted after the resource update. This can be done either through the settings menu by turning off and turning on the device.
У вас нет разрешения на просмотр содержимого!

Although the use of the BipOS loader significantly reduces "breaking" of your watch, you should still be careful. Consider the algorithms of your app, avoid infinite loops, avoid the writing in the memory area not specifically intended for use by your application, etc. Whatever you do, you do so at your own risk, no responsibility for the consequences of your actions is not responsible. This instruction is informational in nature, before performing any action you should be aware of all that you are going to do and what the consequences will come, take these likely consequences.


The development process is discussed in this topic.
 
Последнее редактирование:

MNVolkov

Разработчик
Команда форума
Сообщения
417
Реакции
2,803
Баллы
483
Ваше "умное" устройство
Amazfit Bip
The BipOS SDK for navigation was created based on the learning of the compass. So if there is an error in compass, it has flowed into the SDK that Navigator and GPS Returner are built on. Please check on other firmware, including newer ones, maybe the compass is corrected there, then I can fix it. Thanks.
 

j3v

Новичок
Сообщения
5
Реакции
11
Баллы
23
Ваше "умное" устройство
Amazfit Bip
The BipOS SDK for navigation was created based on the learning of the compass. So if there is an error in compass, it has flowed into the SDK that Navigator and GPS Returner are built on. Please check on other firmware, including newer ones, maybe the compass is corrected there, then I can fix it. Thanks.
I was wrong, the compass app is actually reporting the correct value, I just didn't notice the West indicator once gps loaded.
It looks like it does that rather than providing a negative symbol in front of the degree value.

Here are two images from both 1.1.2.05 and 1.1.5.36:
longitude_error_fw1_1_2_05.jpg longitude_error_fw1_1_5_36.jpg
GPS firmware is up to date as well (18344,eb2f43f,126).
Hardware revision: V0.11.2.4 (CE)

The other thing I noticed is my compass is pointing 180° the wrong direction for both firmware versions. North is South.
Even after a device reboot/firmware flash, and re-calibrating using the figure-8 pattern.
Is it possible this has anything to do with it? Otherwise the compass app is correct and the SDK might be providing the wrong value.

Thanks again for your help!
 

MNVolkov

Разработчик
Команда форума
Сообщения
417
Реакции
2,803
Баллы
483
Ваше "умное" устройство
Amazfit Bip
It is interesting thing. I will try to fix it.
 

Pólux

Разработчик
Команда форума
Сообщения
191
Реакции
453
Баллы
98
Ваше "умное" устройство
Amazfit Bip
@j3v @MNVolkov I think definitions of East/West hemispheres (libbip.h) are swapped. Shouldn't they be
Код:
#define NAVI_EAST_HEMISPHERE    2
#define NAVI_WEST_HEMISPHERE    3
?
 

j3v

Новичок
Сообщения
5
Реакции
11
Баллы
23
Ваше "умное" устройство
Amazfit Bip
@Pólux it looks like

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

is using the proper value though, so I don't think that is the issue:
Код:
 appdata->current_location.longitude = navi_data.longitude / 3000000.0 * (navi_data.ew == 2 ? -1 : 1);
looking at

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

, it looks like this might have gone unnoticed because it's using navi_data.ns for East/West a few times:
Код:
_sprintf(lon, "%c%3d.%.6d", (app_data->navi_data.ns)==NAVI_WEST_HEMISPHERE?'W':'E',
 

Pólux

Разработчик
Команда форума
Сообщения
191
Реакции
453
Баллы
98
Ваше "умное" устройство
Amazfit Bip
@j3v hemisphere check in gps_returner.c is also reversed. It should be
Код:
appdata->current_location.longitude = navi_data.longitude / 3000000.0 * (navi_data.ew == 2 ? 1 : -1);
Yes, you are right about navi_demo lat/lon confusion.
 

j3v

Новичок
Сообщения
5
Реакции
11
Баллы
23
Ваше "умное" устройство
Amazfit Bip
@Pólux I can confirm the changes to the lib and both programs worked for me, thanks for your help!

Looks like a few pull requests might be in order... :rolleyes:
 

j3v

Новичок
Сообщения
5
Реакции
11
Баллы
23
Ваше "умное" устройство
Amazfit Bip
New ELF is freezing watch and triggering a reset, just before showing altitude and coordinates, on 1.1.2.05 BipOS 0.5.3. However compiling it by myself works well. Strange.
The one I compiled works fine as well, just making the navi_data.ns --> navi_data.ew changes and lib changes mentioned above.
Saw the github source updated, possibly the

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

made to main.h are causing the issue?
 

T0ppjohan

Новичок
Сообщения
1
Реакции
0
Баллы
1
Ваше "умное" устройство
Amazfit Bip
Hello, I am trying to find an intervall timer for the bip. Is there anyone here that has a program for that?
 

neonsea

Новичок
Сообщения
1
Реакции
8
Баллы
23
Ваше "умное" устройство
Amazfit Bip
Hi!

I was inspired by @x27's research on hijacking the Bluetooth functionality in the AliPay service and wrote a

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

to let applications use the Bluetooth functionality in patched firmwares. I also wrote the

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

, which is the default BipOS release as of today. In addition, I wrote a

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

of the library.

I was wondering whether future BipOS releases would include the patches required for hijacking the Bluetooth functionality? Additionally, proper relocs for the four functions defined in the library would be nice, instead of hard-coded offsets :) Currently, apps using the library need to target a specific FW version.
 

josehhh

Новичок
Сообщения
14
Реакции
23
Баллы
23
Ваше "умное" устройство
Amazfit Bip
Hi!

I was inspired by @x27's research on hijacking the Bluetooth functionality in the AliPay service and wrote a

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

to let applications use the Bluetooth functionality in patched firmwares. I also wrote the

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

, which is the default BipOS release as of today. In addition, I wrote a

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

of the library.

I was wondering whether future BipOS releases would include the patches required for hijacking the Bluetooth functionality? Additionally, proper relocs for the four functions defined in the library would be nice, instead of hard-coded offsets :) Currently, apps using the library need to target a specific FW version.
This is huge! It opens so many possibilities: interacting with notifications, loading the calendar from the phone... Hopefully it will get added to the default BipOS. It would also be extremelly helpful to have a demo app. Great Work!
 

thichthat

Участник
Сообщения
16
Реакции
148
Баллы
43
Ваше "умное" устройство
Amazfit Bip
Hi @MNVolkov , sorry for disturbing you again.

I have an idea for a notes app:

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.



The idea is that we can send a note via a notification to the watch:
- The title of the notification should start with a pattern, for example @bip
- On launching the program, it scan the last notification to see if it has that title pattern.
- The pointer to the notification struct can be found by decompiling the "add_notification" function. For now, I only have the address for NOT_LATIN_1_1_2_05.
- If the notification does start with @bip pattern, we copy the notification content and save it to the memory using elfWriteSettings

Since I've made 6 slots for saving, we can use @bip1, @bip2,... ,@bip6 for selecting the saving slot.

However, I'm having a trouble with elfWriteSettings. After saving, it crashes the OS and corrupts some memory locations. I could not reboot the watch and I had to drain the battery by turning my watch into an expensive vibrator (LOL 🤣). After that, I re-flashed the resource file and the watch came back to live.

Can you take a look on the file named "

Пожалуйста войдите или зарегистрируйтесь для просмотра скрытого текста.

" to see what is the problem?

Thank you.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу