├── flash_utility ├── backup │ └── readme.md ├── run_linux_in_ram.uu ├── readme.txt ├── firmware │ └── readme.txt ├── boot │ └── readme.txt ├── restore_nand.uu ├── flash_linux_to_nand.uu └── backup_nand.uu └── README.md /flash_utility/backup/readme.md: -------------------------------------------------------------------------------- 1 | NAND backups would be placed in this folder. 2 | 3 | Expect these files: 4 | 5 | - 0-64mb.bin.gz 6 | - 128-192mb.bin.gz 7 | - 192-256mb.bin.gz 8 | - 256-320mb.bin.gz 9 | - 320-384mb.bin.gz 10 | - 384-448mb.bin.gz 11 | - 448-512mb.bin.gz 12 | - 64-128mb.bin.gz 13 | -------------------------------------------------------------------------------- /flash_utility/run_linux_in_ram.uu: -------------------------------------------------------------------------------- 1 | uuu_version 1.2.135 2 | 3 | # This script allows you to run the Linux OS in the RAM without altering the NAND Flash 4 | 5 | SDP: boot -f boot/u-boot-dtb.imx -nojump 6 | SDP: write -f firmware/zImage -addr 0x80800000 7 | SDP: write -f firmware/imx6ull-14x14-prime.dtb -addr 0x83000000 8 | SDP: write -f firmware/rootfs.cpio.uboot -addr 0x86800000 9 | SDP: jump -f boot/u-boot-dtb.imx -ivt 10 | SDP: done 11 | -------------------------------------------------------------------------------- /flash_utility/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | # Flash utility 3 | 4 | See the main readme.md for instructions. 5 | 6 | NOTE: No pre-built binary blobs are stored in this repository. For pre-built binaries, go to GitHub release page and download the release package. 7 | 8 | ## uuu 9 | 10 | UUU (Universal Update Utility) is a Freescale/NXP I.MX Chip image deploy tool. 11 | 12 | To download the tool, go to https://github.com/NXPmicro/mfgtools/releases and download the latest release. A copy of the tool is also provided in the release package. 13 | 14 | -------------------------------------------------------------------------------- /flash_utility/firmware/readme.txt: -------------------------------------------------------------------------------- 1 | These are the images used for the actual Linux OS. 2 | 3 | ```u-boot-dtb.imx``` is the u-boot image that would be either flashed into NAND or run in the RAM. It can be built by following the u-boot building instructions. 4 | 5 | ```zImage``` is the Linux kernel image that would be either flashed into NAND or run in the RAM. It can be built by following the kernel building instructions. 6 | 7 | ```imx6ull-14x14-prime.dtb``` is the device tree blob that would be either flashed into NAND or run in the RAM. It can be built by following the kernel building instructions. 8 | 9 | ```rootfs.tar.bz2``` is used for flashing Linux into the NAND flash. This would be your root filesystem. 10 | 11 | ```rootfs.cpio.uboot``` is used for running Linux in the RAM without modifing the Flash. 12 | -------------------------------------------------------------------------------- /flash_utility/boot/readme.txt: -------------------------------------------------------------------------------- 1 | These are the images used for nand flashing environment. They will not be flashed into NAND Flash, they are only used during flashing process. 2 | 3 | Put ```fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot```, ```zImage```, ```imx6ull-14x14-prime.dtb```, ```u-boot-dtb.imx```, and ```u-boot-dtb-nomtdpart.imx``` here. 4 | 5 | ```fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot``` and ```zImage``` can be found in NXP's Linux OS release (need to be 4.14 or newer, can be found at https://www.nxp.com/design/software/embedded-software/linux-software-and-development-tools/embedded-linux-for-i.mx-applications-processors:IMXLINUX?tab=Design_Tools_Tab). 6 | 7 | ```imx6ull-14x14-prime.dtb``` can be built by following the kernel building instructions. 8 | 9 | ```u-boot-dtb.imx``` can be built by following the uboot building instructions. 10 | 11 | ```u-boot-dtb-nomtdpart.imx``` is a modified version of u-boot, which does not pass NAND partition informations to the kernel, allowing doing operations to the whole NAND flash such as backup and restore the original OS. 12 | -------------------------------------------------------------------------------- /flash_utility/restore_nand.uu: -------------------------------------------------------------------------------- 1 | uuu_version 1.2.135 2 | 3 | # This script allows you to restore the whole NAND flash including OOB data 4 | 5 | # Boot into flash environment 6 | SDP: boot -f boot/u-boot-dtb-nomtdpart.imx -nojump 7 | SDP: write -f boot/zImage -addr 0x80800000 8 | SDP: write -f boot/imx6ull-14x14-prime.dtb -addr 0x83000000 9 | SDP: write -f boot/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot -addr 0x86800000 10 | SDP: jump -f boot/u-boot-dtb-nomtdpart.imx -ivt 11 | 12 | # Limited by the RAM size, restore 64MB at a time 13 | FBK: ucmd flash_erase /dev/mtd0 0 0 14 | 15 | FBK: ucp backup/0-64mb.bin t:/tmp 16 | FBK: ucmd nandwrite --noecc --noskipbad --oob -s 0x0 /dev/mtd0 /tmp/0-64mb.bin 17 | FBK: ucmd rm /tmp/* 18 | 19 | FBK: ucp backup/64-128mb.bin t:/tmp 20 | FBK: ucmd nandwrite --noecc --noskipbad --oob -s 0x4000000 /dev/mtd0 /tmp/64-128mb.bin 21 | FBK: ucmd rm /tmp/* 22 | 23 | FBK: ucp backup/128-192mb.bin t:/tmp 24 | FBK: ucmd nandwrite --noecc --noskipbad --oob -s 0x8000000 /dev/mtd0 /tmp/128-192mb.bin 25 | FBK: ucmd rm /tmp/* 26 | 27 | FBK: ucp backup/192-256mb.bin t:/tmp 28 | FBK: ucmd nandwrite --noecc --noskipbad --oob -s 0xc000000 /dev/mtd0 /tmp/192-256mb.bin 29 | FBK: ucmd rm /tmp/* 30 | 31 | # Done 32 | FBK: done 33 | 34 | -------------------------------------------------------------------------------- /flash_utility/flash_linux_to_nand.uu: -------------------------------------------------------------------------------- 1 | uuu_version 1.2.135 2 | 3 | # This script allows you to flash the Linux OS into NAND Flash. 4 | 5 | # Boot into flash environment 6 | SDP: boot -f boot/u-boot-dtb.imx -nojump 7 | SDP: write -f boot/zImage -addr 0x80800000 8 | SDP: write -f boot/imx6ull-14x14-prime.dtb -addr 0x83000000 9 | SDP: write -f boot/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot -addr 0x86800000 10 | SDP: jump -f boot/u-boot-dtb.imx -ivt 11 | 12 | # Flash uboot 13 | FBK: ucmd mount -t debugfs debugfs /sys/kernel/debug 14 | FBK: ucmd flash_erase /dev/mtd0 0 0 15 | FBK: ucp firmware/u-boot-dtb.imx t:/tmp 16 | FBK: ucmd kobs-ng init -x -v --chip_0_device_path=/dev/mtd0 /tmp/u-boot-dtb.imx 17 | 18 | # Flash kernel 19 | FBK: ucmd flash_erase /dev/mtd1 0 0 20 | FBK: ucp firmware/zImage t:/tmp 21 | FBK: ucmd nandwrite -p /dev/mtd1 /tmp/zImage 22 | 23 | # Flash device tree blob 24 | FBK: ucmd flash_erase /dev/mtd2 0 0 25 | FBK: ucp firmware/imx6ull-14x14-prime.dtb t:/tmp 26 | FBK: ucmd nandwrite -p /dev/mtd2 /tmp/imx6ull-14x14-prime.dtb 27 | 28 | # Flash rootfs 29 | FBK: ucmd flash_erase /dev/mtd4 0 0 30 | FBK: ucmd ubiformat /dev/mtd4 31 | FBK: ucmd ubiattach /dev/ubi_ctrl -m 4 32 | FBK: ucmd ubimkvol /dev/ubi0 -Nrootfs -m 33 | FBK: ucmd mkdir -p /mnt/mtd 34 | FBK: ucmd mount -t ubifs ubi0:rootfs /mnt/mtd 35 | FBK: acmd export EXTRACT_UNSAFE_SYMLINKS=1; tar -jx -C /mnt/mtd 36 | FBK: ucp firmware/rootfs.tar.bz2 t:- 37 | FBK: sync 38 | FBK: ucmd umount /mnt/mtd 39 | 40 | # Done 41 | FBK: done 42 | 43 | -------------------------------------------------------------------------------- /flash_utility/backup_nand.uu: -------------------------------------------------------------------------------- 1 | uuu_version 1.2.135 2 | 3 | # This script allows you to backup the whole NAND flash including OOB data 4 | 5 | # Boot into flash environment 6 | SDP: boot -f boot/u-boot-dtb-nomtdpart.imx -nojump 7 | SDP: write -f boot/zImage -addr 0x80800000 8 | SDP: write -f boot/imx6ull-14x14-prime.dtb -addr 0x83000000 9 | SDP: write -f boot/fsl-image-mfgtool-initramfs-imx_mfgtools.cpio.gz.u-boot -addr 0x86800000 10 | SDP: jump -f boot/u-boot-dtb-nomtdpart.imx -ivt 11 | 12 | # Limited by the RAM size, backup 64MB at a time 13 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/0-64mb.bin -l 0x4000000 -s 0x0 /dev/mtd0 14 | FBK: ucp t:/tmp/0-64mb.bin backup/ 15 | FBK: ucmd rm /tmp/*.bin 16 | 17 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/64-128mb.bin -l 0x4000000 -s 0x4000000 /dev/mtd0 18 | FBK: ucp t:/tmp/64-128mb.bin backup/ 19 | FBK: ucmd rm /tmp/*.bin 20 | 21 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/128-192mb.bin -l 0x4000000 -s 0x8000000 /dev/mtd0 22 | FBK: ucp t:/tmp/128-192mb.bin backup/ 23 | FBK: ucmd rm /tmp/*.bin 24 | 25 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/192-256mb.bin -l 0x4000000 -s 0xc000000 /dev/mtd0 26 | FBK: ucp t:/tmp/192-256mb.bin backup/ 27 | FBK: ucmd rm /tmp/*.bin 28 | 29 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/256-320mb.bin -l 0x4000000 -s 0x10000000 /dev/mtd0 30 | FBK: ucp t:/tmp/256-320mb.bin backup/ 31 | FBK: ucmd rm /tmp/*.bin 32 | 33 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/320-384mb.bin -l 0x4000000 -s 0x14000000 /dev/mtd0 34 | FBK: ucp t:/tmp/320-384mb.bin backup/ 35 | FBK: ucmd rm /tmp/*.bin 36 | 37 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/384-448mb.bin -l 0x4000000 -s 0x18000000 /dev/mtd0 38 | FBK: ucp t:/tmp/384-448mb.bin backup/ 39 | FBK: ucmd rm /tmp/*.bin 40 | 41 | FBK: ucmd nanddump --bb=dumpbad --noecc --oob -f /tmp/448-512mb.bin -l 0x4000000 -s 0x1c000000 /dev/mtd0 42 | FBK: ucmd gzip /tmp/448-512mb.bin 43 | FBK: ucp t:/tmp/448-512mb.bin backup/ 44 | FBK: ucmd rm /tmp/*.bin 45 | 46 | # Done 47 | FBK: done 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HP Prime Linux 2 | 3 | # 0. Overview 4 | 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 | 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 | ``` 285 | --------------------------------------------------------------------------------