Skip to content

Commit 3b41b2e

Browse files
committed
readme: guides
1 parent 9a41604 commit 3b41b2e

File tree

1 file changed

+282
-4
lines changed

1 file changed

+282
-4
lines changed

README.md

Lines changed: 282 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,284 @@
1-
# hp-prime-linux
2-
Tools and scripts for running Linux on HP Prime calculator
1+
# HP Prime Linux
32

4-
## License
3+
# 0. Overview
54

6-
All scripts provided in this repository are released to public domain (if applicable).
5+
This project aims to port Linux OS to the HP Prime calculator. It is based on the Buildroot distribution. Long term goal is providing an alternative OS on Prime that is more capable than the original OS (PPL support, or better RPN support, native binary code execution for sure, and so on).
6+
7+
Please be aware this project is still in its early stages. It is not useful for general use as a calculator OS yet.
8+
9+
**WARNING**: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10+
11+
**WARNING**: The software is not fully tested. Installing it might brick your calculator (unable to boot) or you may lose the ability to install the original (stock) HP Prime OS back. Use it at your own risk.
12+
13+
**WARNING**: None of the software/ documentation/ guide provided shall be used for cheating in the exam. Linux OS shall not be used when using the calculator in the exam or any other cases that doing so would cause academic integrity violations.
14+
15+
If you have any questions, feel free to contact me (zephray at outlook dot com). All scripts are released to public domain (if applicable).
16+
17+
18+
# 1. Status
19+
20+
Linux OS:
21+
22+
- [x] DDR initialization
23+
- [x] U-boot Boot loader
24+
- [x] Basic Linux OS
25+
- [x] LCD controller SPI driver
26+
- [x] LCD fbdev driver
27+
- [x] PWM backlight driver
28+
- [x] Touchscreen driver
29+
- [x] PMIC driver
30+
- [x] keypad driver
31+
- [x] NAND flash driver
32+
- [ ] Standby
33+
34+
Application:
35+
36+
- [ ] Launcher UI
37+
- [ ] System settings UI
38+
39+
More applications T.B.D.
40+
41+
<!-- more -->
42+
43+
# 2. Install
44+
45+
Installing the Linux OS to NAND Flash or running the Linux OS in the RAM requires you to open up the back case of the calculator, which by definition, void your warranty.
46+
47+
You will need:
48+
49+
* A HP Prime G2 calculator (2AP18AA)
50+
* An USB cable (USB A to Micro B) to connect Prime with PC
51+
* A screwdriver
52+
* Tweezers (conductive, or jump wire)
53+
* A PC running either Linux or Windows 7+
54+
* HP-Prime-Linux release package from [https://github.com/zephray/hp-prime-linux/releases](https://github.com/zephray/hp-prime-linux/releases)
55+
56+
## 2.1 Entering the SDP mode
57+
58+
NOTE: If you already have Linux installed, you may just use ```flash_erase /dev/mtd0 0 0``` to erase the boot sector, so after reset it would fail to boot and fallback to the SDP mode.
59+
60+
Open up the calculator case, connect the USB cable to PC and turn on the calculator.
61+
62+
**WARNING**: Please be careful. Shorting the wrong pins may cause irreversible damage to your calculator's hardware.
63+
64+
While the calculator is ON, use tweezers to short these two solder pads and press the RESET button (push button on the back of the keypad). You should see a new USB device called "SE Blank 6ULL" on your PC. (Linux users may use ```lsusb``` to check if there is a new Freescale USB device connected).
65+
66+
![1565879188956-sdp-mode.jpg](https://www.zephray.me/api/media/1565879188956-sdp-mode.jpg)
67+
68+
**NOTE**: The pin you are shorting is the Boot Mode 1 and ground . By default it is pulled up to 3.3V by a 10K pull up resistor.
69+
70+
Now you may follow either of the following options. It is possible to do multiple things consecutively without rebooting your calculator. For example, you may first backup the NAND flash and then flash the Linux OS without rebooting the calculator.
71+
72+
## 2.2 Backup the NAND
73+
74+
**WARNING**: The NAND backup does not utilize any ECC, instead, it will backup the OOB (out-of-band) data as well. It would also backup all bad blocks. In this way, it does not depend on any specific bad block management or ECC schemes. **This means, you may not be able to restore the backup if the nand flash is worn (more bad blocks, more bit errors, etc) over time.** You may also only use your own backup. Backup made on other calculators may not work on your calculator. To be short, *just don't rely on this too much*, I have no idea how reliable it is.
75+
76+
To do so, first put calculator into SDP mode. Open up a command prompt. Change to flash_utility folder.
77+
78+
For Windows users, run
79+
80+
```
81+
uuu backup_nand.uu
82+
```
83+
84+
For Linux users, run
85+
86+
```
87+
sudo ./uuu backup_nand.uu
88+
```
89+
90+
Once it is done, you should see the whole NAND backup in the ```backup``` folder.
91+
92+
## 2.3 Restore the NAND
93+
94+
You should have the whole NAND backup in the ```backup``` folder before proceeding.
95+
96+
To do so, first put calculator into SDP mode. Open up a command prompt. Change to flash_utility folder.
97+
98+
For Windows users, run
99+
100+
```
101+
uuu restore_nand.uu
102+
```
103+
104+
For Linux users, run
105+
106+
```
107+
sudo ./uuu restore_nand.uu
108+
```
109+
110+
## 2.4 Run Linux in the RAM
111+
112+
It is possible to run the Linux OS without overwritting the NAND flash. However, you would need to enter SDP mode and use USB to sideload everything every time you want to use Linux.
113+
114+
**WARNING**: This should not corrupt your original OS. However, doing so may still cause irreversible damage to your hardware due to possible bugs in the code.
115+
116+
**NOTE**: When running in the RAM, the root filesystem image size should not exceed ~15MB, otherwise it won't boot.
117+
118+
To do so, first put calculator into SDP mode. Open up a command prompt. Change to flash_utility folder.
119+
120+
For Windows users, run
121+
122+
```
123+
uuu run_linux_in_ram.uu
124+
```
125+
126+
For Linux users, run
127+
128+
```
129+
sudo ./uuu run_linux_in_ram.uu
130+
```
131+
132+
Now the calculator should boot into Linux. Use root to login.
133+
134+
## 2.5 Flash Linux in to the NAND
135+
136+
**WARNING**: Make sure you have a full NAND backup before proceeding. However, there is no gaurantee that you can always restore the NAND backup for the reason stated before in the backup section.
137+
138+
**WARNING**: Doing so may still cause irreversible damage to your hardware due to possible bugs in the code.
139+
140+
To do so, first put calculator into SDP mode. Open up a command prompt. Change to flash_utility folder.
141+
142+
For Windows users, run
143+
144+
```
145+
uuu flash_linux_to_nand.uu
146+
```
147+
148+
For Linux users, run
149+
150+
```
151+
sudo ./uuu flash_linux_to_nand.uu
152+
```
153+
154+
It would take several minutes to complete. Once done, reset the calculator, it should boot into Linux. It would take ~15 seconds to boot into system. Use root to login.
155+
156+
# 3. Use
157+
158+
Currently there isn't much to play with.
159+
160+
## 3.1 USB Serial Console
161+
162+
You can use a USB cable to connect the calculator to PC and access the Linux console from your PC. It should show up as a USB serial device. Use Tera Term, PuTTY, SecureCRT, minicom, or other similar tools to connect to the board. Because it is not acutall serial port, baud rate doesn't matter. You may use any baud rate you want.
163+
164+
# 4. Compile from source
165+
166+
The following are tested under Ubuntu 18.04 LTS. It is recommended to compile under Linux host.
167+
168+
## 4.1 u-boot
169+
170+
Normally you don't need to recompile the u-boot. The following instructions are provided as reference.
171+
172+
To compile the u-boot from source:
173+
174+
```sh
175+
git clone git://github.com/zephray/uboot.git
176+
cd uboot
177+
git checkout imx_v2018.03_4.14.98_2.0.0_ga
178+
make mx6ull_prime_defconfig
179+
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make
180+
```
181+
182+
```u-boot-dtb.imx``` is the compiled binary.
183+
184+
## 4.2 Kernel
185+
186+
If you want to enable or disable certain driver/ kernel moudles, you would need to recompile the kernel.
187+
188+
```sh
189+
git clone git://github.com/zephray/linux.git
190+
cd linux
191+
git checkout imx_4.14.98_2.0.0_ga
192+
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make hp_prime_defconfig
193+
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make
194+
```
195+
196+
```arch/arm/boot/dts/imx6ull-14x14-prime.dts``` and ```arch/arm/boot/zImage``` are the compiled binaries.
197+
198+
## 4.3 Root Filesystem
199+
200+
Currently hp-prime-linux uses buildroot to construct the root filesystem. Currently there is no package manager, if you need to add or remove package, you would need to rebuild the rootfs.
201+
202+
```sh
203+
git clone git://git.buildroot.net/buildroot
204+
wget https://raw.githubusercontent.com/zephray/hp-prime-linux/master/buildroot/config
205+
mv config .config
206+
cd buildroot
207+
make
208+
```
209+
210+
To install kernel modules to your rootfs, go to kernel directory, run the following commands:
211+
212+
```sh
213+
INSTALL_MOD_PATH=~/buildroot/output/target ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make modules_install
214+
```
215+
216+
And run the make in the buildroot again to regenerate images.
217+
218+
# 5. Configure the system
219+
220+
## 5.1 uboot
221+
222+
Normally the u-boot already contains all the necessary settings to boot from RAM or NAND. However, if needed, you may boot the OS manually using the following commands via serial console:
223+
224+
```
225+
nand read ${loadaddr} 0x400000 0x800000
226+
nand read ${fdt_addr} 0xc00000 0x100000
227+
bootz ${loadaddr} - ${fdt_addr}
228+
```
229+
230+
To change default boot commands, look into ```include/configs/mx6ull_prime.h```.
231+
232+
## 5.2 kernel
233+
234+
### 5.2.1 Kernel configuration
235+
236+
Use ```make menuconfig``` to enable or disable modules.
237+
238+
### 5.2.2 Keypad mapping
239+
240+
Keypad mapping can be modified in ```arch/arm/boot/dts/imx6ull-14x14-prime.dts```. However, for future software compatibility concerns, it is not recommended to modify it.
241+
242+
## 5.3 OS
243+
244+
### 5.3.1 Enable new packages
245+
246+
To enable new packages, goto
247+
248+
### 5.3.2 Enable the USB serial console
249+
250+
In the release, this is enabled by default. However, if you are building your own rootfs, you may want to enable this.
251+
252+
USB serial gadget need to be compiled as a module and probed at runtime. Make sure your rootfs have that module. See the building rootfs section for details
253+
254+
Write the config so it would probe the module automatically during start up:
255+
256+
```sh
257+
vi ~/buildroot/output/target/etc/init.d/S03modules
258+
```
259+
260+
Type in the following:
261+
262+
```sh
263+
#!/bin/sh
264+
265+
case "$1" in
266+
start)
267+
modprobe g_serial
268+
;;
269+
*)
270+
exit 1
271+
;;
272+
esac
273+
```
274+
Enable console on the USB serial:
275+
276+
```sh
277+
vi ~/buildroot/output/target/etc/inittab
278+
```
279+
280+
Type in the following:
281+
282+
```sh
283+
ttyGS0::respawn:/sbin/getty -L ttyGS0 115200 vt100 # USB SERIAL
284+
```

0 commit comments

Comments
 (0)