Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

computed checksum did NOT match #33

Open
nbritton opened this issue Apr 30, 2020 · 87 comments
Open

computed checksum did NOT match #33

nbritton opened this issue Apr 30, 2020 · 87 comments

Comments

@nbritton
Copy link

nbritton commented Apr 30, 2020

root@ubuntu:~/airbreak# ./patch-airsense stm32.bin stm32-unlocked.bin
stm32.bin: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match
stm32.bin: wrong hash

SW firmware version on my device is SX567-0306, it's been unplugged for about six months so I guess it did not receive the over the air updates to version SX567-0401. I don't know how to trigger the OTA firmware update process, I don't have a DME provider so I'm not even sure this unit can receive the update. The machine has one bar on the modem signal status. Is there a way to download the stock firmware update version SX567-0401 on the Internet?

root@ubuntu:~/airbreak# sha256sum stm32.bin
363a204ba217f31223e929365d58b8f5ce038a7681e362fe157e190c2eacbd30 stm32.bin

@nbritton
Copy link
Author

I changed the sha256 checksum in the bash script to match my v306 firmware and flashed the device anyways. The flash appears to have worked because my machine now says "HACKED!". However, none of the extra options show up in the mode menu, it just shows CPAP and Autoset.

@nbritton
Copy link
Author

I flashed the machine back to the stock firmware, that appears to have worked as expected... the machine no longer says "HACKED!". I reset the Redmed machine with a power cycle. However, I now get this message on the Raspberry Pi...

root@ubuntu:~/airbreak# openocd -f ./tcl/airsense.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: srst = 18
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_push_pull connect_deassert_srst
cortex_m reset_config sysresetreq
Info : replaced existing 'mrw' usage
Info : replaced existing 'mrw' help
Info : replaced existing 'mrb' usage
Info : replaced existing 'mrb' help
Info : replaced existing 'mmw' usage
Info : replaced existing 'mmw' help
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 2002 kHz
in procedure 'init' called at file "./tcl/airsense.cfg", line 77
in procedure 'ocd_bouncer'

@nbritton
Copy link
Author

root@ubuntu:~/airbreak# openocd -f ./tcl/airsense.cfg -d 3
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
User : 13 5 command.c:544 command_print(): debug_level: 3
Debug: 14 6 options.c:181 add_default_dirs(): bindir=/usr/bin
Debug: 15 6 options.c:182 add_default_dirs(): pkgdatadir=/usr/share/openocd
Debug: 16 6 options.c:183 add_default_dirs(): exepath=/usr/bin
Debug: 17 6 options.c:184 add_default_dirs(): bin2data=../share/openocd
Debug: 18 6 configuration.c:42 add_script_search_dir(): adding /root/.openocd
Debug: 19 6 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/site
Debug: 20 6 configuration.c:42 add_script_search_dir(): adding /usr/bin/../share/openocd/scripts
Debug: 21 6 configuration.c:82 find_file(): found ./tcl/airsense.cfg
Debug: 22 6 configuration.c:82 find_file(): found /usr/bin/../share/openocd/scripts/interface/raspberrypi2-native.cfg
Debug: 23 6 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_interface bcm2835gpio
Debug: 24 7 command.c:143 script_debug(): command - interface ocd_interface bcm2835gpio
Debug: 26 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_jtag_nums'...
Debug: 27 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_tck_num' does not have the '.usage' field filled out
Debug: 28 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_tck_num'...
Debug: 29 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_tms_num' does not have the '.usage' field filled out
Debug: 30 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_tms_num'...
Debug: 31 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_tdo_num' does not have the '.usage' field filled out
Debug: 32 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_tdo_num'...
Debug: 33 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_tdi_num' does not have the '.usage' field filled out
Debug: 34 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_tdi_num'...
Debug: 35 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_swd_nums'...
Debug: 36 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_swclk_num' does not have the '.usage' field filled out
Debug: 37 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_swclk_num'...
Debug: 38 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_swdio_num' does not have the '.usage' field filled out
Debug: 39 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_swdio_num'...
Debug: 40 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_srst_num' does not have the '.usage' field filled out
Debug: 41 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_srst_num'...
Debug: 42 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_trst_num' does not have the '.usage' field filled out
Debug: 43 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_trst_num'...
Debug: 44 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_speed_coeffs' does not have the '.usage' field filled out
Debug: 45 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_speed_coeffs'...
Debug: 46 7 command.c:319 command_new(): BUG: command 'bcm2835gpio_peripheral_base' does not have the '.usage' field filled out
Debug: 47 7 command.c:364 register_command_handler(): registering 'ocd_bcm2835gpio_peripheral_base'...
Debug: 48 7 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_bcm2835gpio_peripheral_base 0x3F000000
Debug: 49 8 command.c:143 script_debug(): command - bcm2835gpio_peripheral_base ocd_bcm2835gpio_peripheral_base 0x3F000000
Debug: 51 8 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_bcm2835gpio_speed_coeffs 146203 36
Debug: 52 8 command.c:143 script_debug(): command - bcm2835gpio_speed_coeffs ocd_bcm2835gpio_speed_coeffs 146203 36
Debug: 54 8 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_bcm2835gpio_swd_nums 25 24
Debug: 55 8 command.c:143 script_debug(): command - bcm2835gpio_swd_nums ocd_bcm2835gpio_swd_nums 25 24
User : 57 8 command.c:544 command_print(): BCM2835 GPIO nums: swclk = 25, swdio = 24
Debug: 58 8 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_bcm2835gpio_srst_num 18
Debug: 59 8 command.c:143 script_debug(): command - bcm2835gpio_srst_num ocd_bcm2835gpio_srst_num 18
User : 61 8 command.c:544 command_print(): BCM2835 GPIO config: srst = 18
Debug: 62 8 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_reset_config srst_only srst_push_pull
Debug: 63 8 command.c:143 script_debug(): command - reset_config ocd_reset_config srst_only srst_push_pull
User : 65 8 command.c:544 command_print(): srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
Debug: 66 8 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select swd
Debug: 67 8 command.c:143 script_debug(): command - ocd_transport ocd_transport select swd
Debug: 68 8 command.c:319 command_new(): BUG: command 'swd' does not have the '.usage' field filled out
Debug: 69 8 command.c:364 register_command_handler(): registering 'ocd_swd'...
Debug: 70 8 bitbang.c:353 bitbang_swd_init(): bitbang_swd_init
Debug: 71 9 configuration.c:82 find_file(): found /usr/bin/../share/openocd/scripts/target/stm32f4x.cfg
Debug: 72 9 configuration.c:82 find_file(): found /usr/bin/../share/openocd/scripts/target/swj-dp.tcl
Debug: 73 9 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 74 9 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 75 9 configuration.c:82 find_file(): found /usr/bin/../share/openocd/scripts/mem_helper.tcl
Debug: 76 9 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_usage_text mrw address
Debug: 77 10 command.c:143 script_debug(): command - add_usage_text ocd_add_usage_text mrw address
Debug: 79 10 command.c:1098 help_add_command(): added 'mrw' help text
Debug: 80 10 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_help_text mrw Returns value of word in memory.
Debug: 81 10 command.c:143 script_debug(): command - add_help_text ocd_add_help_text mrw Returns value of word in memory.
Debug: 83 10 command.c:1111 help_add_command(): added 'mrw' help text
Debug: 84 10 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_usage_text mrb address
Debug: 85 10 command.c:143 script_debug(): command - add_usage_text ocd_add_usage_text mrb address
Debug: 87 10 command.c:1098 help_add_command(): added 'mrb' help text
Debug: 88 10 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_help_text mrb Returns value of byte in memory.
Debug: 89 10 command.c:143 script_debug(): command - add_help_text ocd_add_help_text mrb Returns value of byte in memory.
Debug: 91 10 command.c:1111 help_add_command(): added 'mrb' help text
Debug: 92 10 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_usage_text mmw address setbits clearbits
Debug: 93 10 command.c:143 script_debug(): command - add_usage_text ocd_add_usage_text mmw address setbits clearbits
Debug: 95 10 command.c:1098 help_add_command(): added 'mmw' help text
Debug: 96 10 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 97 10 command.c:143 script_debug(): command - add_help_text ocd_add_help_text mmw Modify word in memory. new_val = (old_val & ~clearbits) | setbits;
Debug: 99 10 command.c:1111 help_add_command(): added 'mmw' help text
Debug: 100 11 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 101 11 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 102 11 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 103 11 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 104 11 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 105 11 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 106 11 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 107 11 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 108 11 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_swd newdap stm32f4x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x2ba01477
Debug: 109 11 command.c:143 script_debug(): command - ocd_swd ocd_swd newdap stm32f4x cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x2ba01477
Debug: 110 11 tcl.c:548 jim_newtap_cmd(): Creating New Tap, Chip: stm32f4x, Tap: cpu, Dotted: stm32f4x.cpu, 8 params
Debug: 111 11 core.c:1300 jtag_tap_init(): Created Tap: stm32f4x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 112 12 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 113 12 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 114 12 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_target create stm32f4x.cpu cortex_m -endian little -chain-position stm32f4x.cpu
Debug: 115 12 command.c:143 script_debug(): command - ocd_target ocd_target create stm32f4x.cpu cortex_m -endian little -chain-position stm32f4x.cpu
Debug: 116 12 target.c:1899 target_free_all_working_areas_restore(): freeing all working areas
Debug: 117 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 118 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 119 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 120 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 121 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 122 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 123 12 command.c:364 register_command_handler(): registering 'ocd_arm'...
Debug: 124 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 125 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 126 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 127 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 128 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 129 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 130 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 131 12 command.c:364 register_command_handler(): registering 'ocd_dap'...
Debug: 132 13 command.c:364 register_command_handler(): registering 'ocd_tpiu'...
Debug: 133 13 command.c:364 register_command_handler(): registering 'ocd_itm'...
Debug: 134 13 command.c:364 register_command_handler(): registering 'ocd_itm'...
Debug: 135 13 command.c:364 register_command_handler(): registering 'ocd_cortex_m'...
Debug: 136 13 command.c:364 register_command_handler(): registering 'ocd_cortex_m'...
Debug: 137 13 command.c:364 register_command_handler(): registering 'ocd_cortex_m'...
Debug: 138 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 139 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 140 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 141 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 142 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 143 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 144 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 145 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 146 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 147 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 148 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 149 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 150 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 151 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 152 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 153 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 154 13 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 155 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 156 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 157 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 158 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 159 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 160 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 161 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 162 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 163 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 164 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 165 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 166 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 167 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 168 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 169 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 170 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 171 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 172 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 173 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 174 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 175 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 176 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 177 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 178 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 179 14 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 180 15 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 181 15 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 182 15 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 183 15 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 184 15 command.c:364 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 185 15 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x8000 -work-area-backup 0
Debug: 186 15 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x8000 -work-area-backup 0
Debug: 187 15 target.c:1899 target_free_all_working_areas_restore(): freeing all working areas
Debug: 188 15 target.c:1899 target_free_all_working_areas_restore(): freeing all working areas
Debug: 189 15 target.c:1899 target_free_all_working_areas_restore(): freeing all working areas
Debug: 190 15 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 191 15 command.c:143 script_debug(): command - ocd_flash ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 193 15 command.c:364 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 194 15 command.c:364 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 195 15 command.c:364 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 196 15 command.c:364 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 197 15 command.c:364 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 198 16 tcl.c:1033 handle_flash_bank_command(): 'stm32f2x' driver usage field missing
Debug: 199 16 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_adapter_khz 2000
Debug: 200 16 command.c:143 script_debug(): command - adapter_khz ocd_adapter_khz 2000
Debug: 202 16 core.c:1631 jtag_config_khz(): handle jtag khz
Debug: 203 16 core.c:1598 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 204 16 core.c:1598 adapter_khz_to_speed(): convert khz to interface specific speed value
User : 205 16 command.c:544 command_print(): adapter speed: 2000 kHz
Debug: 206 16 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_adapter_nsrst_delay 100
Debug: 207 16 command.c:143 script_debug(): command - adapter_nsrst_delay ocd_adapter_nsrst_delay 100
User : 209 16 command.c:544 command_print(): adapter_nsrst_delay: 100
Debug: 210 16 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 211 16 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 212 16 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_reset_config srst_nogate
Debug: 213 16 command.c:143 script_debug(): command - reset_config ocd_reset_config srst_nogate
User : 215 16 command.c:544 command_print(): srst_only separate srst_nogate srst_push_pull connect_deassert_srst
Debug: 216 16 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport select
Debug: 217 16 command.c:143 script_debug(): command - ocd_transport ocd_transport select
Debug: 218 17 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_cortex_m reset_config sysresetreq
Debug: 219 17 command.c:143 script_debug(): command - ocd_cortex_m ocd_cortex_m reset_config sysresetreq
User : 221 17 command.c:544 command_print(): cortex_m reset_config sysresetreq
Debug: 222 17 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event examine-end
# Enable debug during low power modes (uses more power)
# DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP
mmw 0xE0042004 0x00000007 0

# Stop watchdog counters during halt
# DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
mmw 0xE0042008 0x00001800 0

Debug: 223 17 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event examine-end
# Enable debug during low power modes (uses more power)
# DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP
mmw 0xE0042004 0x00000007 0

# Stop watchdog counters during halt
# DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
mmw 0xE0042008 0x00001800 0

Debug: 224 17 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event trace-config
# Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
# change this value accordingly to configure trace pins
# assignment
mmw 0xE0042004 0x00000020 0

Debug: 225 17 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event trace-config
# Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
# change this value accordingly to configure trace pins
# assignment
mmw 0xE0042004 0x00000020 0

Debug: 226 17 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event reset-init
# Configure PLL to boost clock to HSI x 4 (64 MHz)
mww 0x40023804 0x08012008 ;# RCC_PLLCFGR 16 Mhz /8 (M) * 128 (N) /4(P)
mww 0x40023C00 0x00000102 ;# FLASH_ACR = PRFTBE | 2(Latency)
mmw 0x40023800 0x01000000 0 ;# RCC_CR |= PLLON
sleep 10 ;# Wait for PLL to lock
mmw 0x40023808 0x00001000 0 ;# RCC_CFGR |= RCC_CFGR_PPRE1_DIV2
mmw 0x40023808 0x00000002 0 ;# RCC_CFGR |= RCC_CFGR_SW_PLL

# Boost JTAG frequency
adapter_khz 8000

Debug: 227 17 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event reset-init
# Configure PLL to boost clock to HSI x 4 (64 MHz)
mww 0x40023804 0x08012008 ;# RCC_PLLCFGR 16 Mhz /8 (M) * 128 (N) /4(P)
mww 0x40023C00 0x00000102 ;# FLASH_ACR = PRFTBE | 2(Latency)
mmw 0x40023800 0x01000000 0 ;# RCC_CR |= PLLON
sleep 10 ;# Wait for PLL to lock
mmw 0x40023808 0x00001000 0 ;# RCC_CFGR |= RCC_CFGR_PPRE1_DIV2
mmw 0x40023808 0x00000002 0 ;# RCC_CFGR |= RCC_CFGR_SW_PLL

# Boost JTAG frequency
adapter_khz 8000

Debug: 228 18 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event reset-start
# Reduce speed since CPU speed will slow down to 16MHz with the reset
adapter_khz 2000

Debug: 229 18 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event reset-start
# Reduce speed since CPU speed will slow down to 16MHz with the reset
adapter_khz 2000

Debug: 230 18 configuration.c:82 find_file(): found tcl/airsense-info.tcl
Debug: 231 18 configuration.c:82 find_file(): found tcl/airsense-waveform.tcl
Debug: 232 18 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_init
Debug: 233 18 command.c:143 script_debug(): command - init ocd_init
Debug: 235 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_target init
Debug: 236 19 command.c:143 script_debug(): command - ocd_target ocd_target init
Debug: 238 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_target names
Debug: 239 19 command.c:143 script_debug(): command - ocd_target ocd_target names
Debug: 240 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu cget -event gdb-flash-erase-start
Debug: 241 19 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu cget -event gdb-flash-erase-start
Debug: 242 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event gdb-flash-erase-start reset init
Debug: 243 19 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event gdb-flash-erase-start reset init
Debug: 244 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu cget -event gdb-flash-write-end
Debug: 245 19 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu cget -event gdb-flash-write-end
Debug: 246 19 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -event gdb-flash-write-end reset halt
Debug: 247 19 command.c:143 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -event gdb-flash-write-end reset halt
Debug: 248 20 target.c:1324 handle_target_init_command(): Initializing targets...
Debug: 249 20 command.c:364 register_command_handler(): registering 'ocd_target_request'...
Debug: 250 20 command.c:364 register_command_handler(): registering 'ocd_trace'...
Debug: 251 20 command.c:364 register_command_handler(): registering 'ocd_trace'...
Debug: 252 20 command.c:364 register_command_handler(): registering 'ocd_fast_load_image'...
Debug: 253 20 command.c:364 register_command_handler(): registering 'ocd_fast_load'...
Debug: 254 20 command.c:364 register_command_handler(): registering 'ocd_profile'...
Debug: 255 20 command.c:364 register_command_handler(): registering 'ocd_virt2phys'...
Debug: 256 20 command.c:364 register_command_handler(): registering 'ocd_reg'...
Debug: 257 20 command.c:364 register_command_handler(): registering 'ocd_poll'...
Debug: 258 20 command.c:364 register_command_handler(): registering 'ocd_wait_halt'...
Debug: 259 20 command.c:364 register_command_handler(): registering 'ocd_halt'...
Debug: 260 20 command.c:364 register_command_handler(): registering 'ocd_resume'...
Debug: 261 20 command.c:364 register_command_handler(): registering 'ocd_reset'...
Debug: 262 20 command.c:364 register_command_handler(): registering 'ocd_soft_reset_halt'...
Debug: 263 20 command.c:364 register_command_handler(): registering 'ocd_step'...
Debug: 264 20 command.c:364 register_command_handler(): registering 'ocd_mdw'...
Debug: 265 20 command.c:364 register_command_handler(): registering 'ocd_mdh'...
Debug: 266 20 command.c:364 register_command_handler(): registering 'ocd_mdb'...
Debug: 267 20 command.c:364 register_command_handler(): registering 'ocd_mww'...
Debug: 268 20 command.c:364 register_command_handler(): registering 'ocd_mwh'...
Debug: 269 21 command.c:364 register_command_handler(): registering 'ocd_mwb'...
Debug: 270 21 command.c:364 register_command_handler(): registering 'ocd_bp'...
Debug: 271 21 command.c:364 register_command_handler(): registering 'ocd_rbp'...
Debug: 272 21 command.c:364 register_command_handler(): registering 'ocd_wp'...
Debug: 273 21 command.c:364 register_command_handler(): registering 'ocd_rwp'...
Debug: 274 21 command.c:364 register_command_handler(): registering 'ocd_load_image'...
Debug: 275 21 command.c:364 register_command_handler(): registering 'ocd_dump_image'...
Debug: 276 21 command.c:364 register_command_handler(): registering 'ocd_verify_image_checksum'...
Debug: 277 21 command.c:364 register_command_handler(): registering 'ocd_verify_image'...
Debug: 278 21 command.c:364 register_command_handler(): registering 'ocd_test_image'...
Debug: 279 21 command.c:364 register_command_handler(): registering 'ocd_reset_nag'...
Debug: 280 21 command.c:364 register_command_handler(): registering 'ocd_ps'...
Debug: 281 21 command.c:364 register_command_handler(): registering 'ocd_test_mem_access'...
Info : 282 21 bcm2835gpio.c:428 bcm2835gpio_init(): BCM2835 GPIO JTAG/SWD bitbang driver
Info : 283 21 bcm2835gpio.c:440 bcm2835gpio_init(): SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Debug: 284 21 bcm2835gpio.c:505 bcm2835gpio_init(): saved pinmux settings: tck 0 tms 0 tdi 0 tdo 0 trst 0 srst 0
Debug: 285 21 bitbang.c:408 bitbang_switch_to_swd(): bitbang_switch_to_swd
Debug: 286 21 bitbang.c:360 bitbang_exchange(): bitbang_exchange
Debug: 287 21 core.c:1598 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 288 21 core.c:1601 adapter_khz_to_speed(): have interface set up
Debug: 289 21 core.c:1598 adapter_khz_to_speed(): convert khz to interface specific speed value
Debug: 290 21 core.c:1601 adapter_khz_to_speed(): have interface set up
Info : 291 21 core.c:1386 adapter_init(): clock speed 2002 kHz
Debug: 292 21 openocd.c:140 handle_init_command(): Debug Adapter init complete
Debug: 293 22 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_transport init
Debug: 294 22 command.c:143 script_debug(): command - ocd_transport ocd_transport init
Debug: 296 22 transport.c:239 handle_transport_init(): handle_transport_init
Debug: 297 22 bitbang.c:383 bitbang_swd_switch_seq(): bitbang_swd_switch_seq
Debug: 298 22 bitbang.c:391 bitbang_swd_switch_seq(): JTAG-to-SWD
Debug: 299 22 bitbang.c:360 bitbang_exchange(): bitbang_exchange
Debug: 300 22 bitbang.c:420 bitbang_swd_read_reg(): bitbang_swd_read_reg
Debug: 301 22 bitbang.c:360 bitbang_exchange(): bitbang_exchange
Debug: 302 22 bitbang.c:360 bitbang_exchange(): bitbang_exchange
Debug: 303 22 bitbang.c:442 bitbang_swd_read_reg(): JUNK DP read reg 0 = ffffffff
Debug: 304 22 bitbang.c:470 bitbang_swd_read_reg(): No valid acknowledge: ack=7
Debug: 305 22 bitbang.c:479 bitbang_swd_write_reg(): bitbang_swd_write_reg
Debug: 306 22 bitbang.c:483 bitbang_swd_write_reg(): Skip bitbang_swd_write_reg because queued_retval=7
Debug: 307 22 bitbang.c:531 bitbang_swd_run_queue(): bitbang_swd_run_queue
Debug: 308 22 bitbang.c:360 bitbang_exchange(): bitbang_exchange
Debug: 309 22 bitbang.c:538 bitbang_swd_run_queue(): SWD queue return value: 07
Debug: 310 22 command.c:626 run_command(): Command failed with error code 7
User : 311 22 command.c:687 command_run_line(): in procedure 'init' called at file "./tcl/airsense.cfg", line 78
in procedure 'ocd_bouncer'
Debug: 312 22 command.c:626 run_command(): Command failed with error code -4
User : 313 23 command.c:687 command_run_line():

@nbritton
Copy link
Author

nbritton commented Apr 30, 2020

I very briefly had it working after I shorted RST to v3.3 (R-Pi pin 1)... the following was output to the terminal... I'm wondering if maybe I have a loose wiring? I soldered them to the board and they seem solidly attached to the pads. However, when I wiggle SWDIO and restart openocd it sometimes briefly works (gets to the dump message). I'm struggling to isolate the wire or figure out a pattern to help me troubleshoot. I didn't find any issues yet with a multimeter continuity test. I guess I'll try resoldering the connection tomorrow.

root@ubuntu:~/airbreak# openocd -f ./tcl/airsense.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: srst = 18
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_push_pull connect_deassert_srst
cortex_m reset_config sysresetreq
Info : replaced existing 'mrw' usage
Info : replaced existing 'mrw' help
Info : replaced existing 'mrb' usage
Info : replaced existing 'mrb' help
Info : replaced existing 'mmw' usage
Info : replaced existing 'mmw' help
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 2002 kHz
Info : SWD DPIDR 0x2ba01477
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
This device is not running modified firmware.
File stm32.bin not found!
Backup of stock firmware image not found.
Please type 'dump' to save the stock firmware to disk.

Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 100ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 300ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 700ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 1500ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 3100ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 6300ms
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Could not initialize the debug port
Examination failed, GDB will be halted. Polling again in 6300ms
^C

@dblunk88
Copy link

Just a FYI: I'm running into the same checksum mismatch and I have the same checksum as you

@dblunk88
Copy link

dblunk88 commented Apr 30, 2020

Confirmed: Hash is equivalent to SW version: SX567-0306

Running also in the same issues as you. One bar and unable to force an OTA update.

@nbritton
Copy link
Author

Good news, it turns out it was a bad connection on the SWDIO wire, I desoldered the old wire and cleaned up the pad and soldered on an entirely new wire. Now openocd is working as expected on the very first attempt. The old wire didn't fail continuity testing, but I think the problem was the wire just had very high resistance relatively speaking that was degrading the digital signaling... the pad is so small and maybe the rosin core I used was interfering with the little bit of contact surface... I don't know, but openocd is working now!

Now I just need to figure out how to injects the rights bits in the right places with the v306 firmware that I have, but ideally I would like to figure out how to upgrade my machine to v401.

@dblunk88
Copy link

Is there a reason why we aren't sharing the firmware dumps? This would make it a lot easier for people who haven't been getting OTA updates

@colinoflynn
Copy link
Collaborator

The firmware is copyright material, and should never be shared (or even links to such material submitted). People doing so would jeopardize the entire project.

Note that the same SW version number encompasses a large group of potentially incompatible firmware as as well. The firmware (and location of stuff) changes also with the 'catalog no' on the back. It's possible some catalog no's are never OTA to the latest FW version as well, which could be due to compatibility reasons for example.

@dblunk88
Copy link

Aw, that makes sense! Thank you for the clarification and for all of the hard work you and others have put in to this project.

@nbritton
Copy link
Author

This is from the patch-airsense script:

extra_modes() {
BUILD_FLAGS=$(( BUILD_FLAGS | (1 << 3) ))
# add more mode entries, set config 0x0 mask to all bits high
# default is 0x3, which only enables mode 1 (CPAP) and 2 (AutoSet)
# ---> This is the real magic <---
printf '\xff\xff' | patch 0x8590 || die failed
}

From someone who has a v401 firmware, what exactly is located at 0x8590? I'm wondering if I can use xxd and just grep for that string to find the correct location in my v306 firmware to patch. A grep for just 0303 returns too many entries.

@gszakacs
Copy link

Is there a reason why we aren't sharing the firmware dumps? This would make it a lot easier for people who haven't been getting OTA updates

It does not appear that the manufacturer is pushing updates to devices, It seems that patients need to go to their doctor to have the devices updated to newer firmware versions.

Ref: http://www.apneaboard.com/forums/Thread-Resmed-Airsense-10-Autoset-firmware-update?page=3

@dblunk88
Copy link

dblunk88 commented Apr 30, 2020

From someone who has a v401 firmware, what exactly is located at 0x8590? I'm wondering if I can use xxd and just grep for that string to find the correct location in my v306 firmware to patch. A grep for just 0303 returns too many entries.

I've asked around and may have found a friend with the newer firmware who would let me borrow his device. Since I'd have access to both dumps, I could see if I can compare both

@nbritton
Copy link
Author

nbritton commented Apr 30, 2020

I have new modes now after my latest flash:

IMG_4176

IMG_4177

screenshot1

root@ubuntu:~/airbreak# git diff patch-airsense
diff --git a/patch-airsense b/patch-airsense
index b0e58d4..4b315e2 100755
--- a/patch-airsense
+++ b/patch-airsense
@@ -20,7 +20,7 @@ patch() {
        dd bs=1 seek=$offset conv=notrunc of="$OUT" status=none
 }

-echo "533b91127aa22e05b933db203ad56c449dc12a8c3fd62f57bd88c472a8061775  $IN"\
+echo "363a204ba217f31223e929365d58b8f5ce038a7681e362fe157e190c2eacbd30  $IN"\
 | sha256sum --check \
 || die "$IN: wrong hash"

@@ -32,8 +32,8 @@ printf '\xc0\x46' | patch 0xf0 \

 # and add a message so that we know this is a modified firmware
 printf 'HACKED!' | patch 0x17500 || die failed
-printf 'NOT FOR USE\x0' | patch 0x1a540 || die failed
-printf 'WARNING! WARNING! Ventilator test firmware: Not for humans!\x00' | patch 0x1b860 || die failed
+#printf 'NOT FOR USE\x0' | patch 0x1a540 || die failed
+#printf 'WARNING! WARNING! Ventilator test firmware: Not for humans!\x00' | patch 0x1b860 || die failed

 BUILD_FLAGS=0

@@ -115,12 +115,12 @@ gui_config () {
        done
 }

-patch_code
-unlock_ui_limits
-extra_debug
+#patch_code
+#unlock_ui_limits
+#extra_debug
 extra_modes
 extra_menu
-#all_menu
+all_menu
 gui_config

 FLAGSTR=$(printf 'FLAGS=0x%02x' $BUILD_FLAGS)

@dblunk88
Copy link

I have new modes now after my latest flash:

Oh nice! Is everything working?

@nbritton
Copy link
Author

nbritton commented Apr 30, 2020

Still playing with it, not even sure what half the features do! However, the first one I tried, ASVAuto, appears to be working... because if I pause my breath for a few seconds the machine will increase the pressure to force me to inhale.

The screen has some non-sense on it too...

IMG_4178

root@ubuntu:~/airbreak# xxd stm32-unlocked.bin | egrep "(GIT|FLAGS)="
00017580: 6e67 656e 0000 0000 464c 4147 533d 3078  ngen....FLAGS=0x
--
00017760: 656e 0000 4749 543d 6165 6331 3938 6100  en..GIT=aec198a.

@dblunk88
Copy link

iVaps has been acting strange for me, just wondering if it is the same for you

@nbritton
Copy link
Author

nbritton commented May 1, 2020

I'm not even sure what that is so I'm probably not the best person to ask if it's operating normally. I'll do what I can to help out converting these to emergency ventilators, but I came here primarily for enabling BiPAP / ASVAuto functionality on my own personal machine. I'm a computer systems engineer who also likes to do electrical engineering as a hobby, so I was compelled to pull mine apart and tinker with it. :-)

image

@nbritton
Copy link
Author

nbritton commented May 1, 2020

Yes absolutely, I think that is critical for enabling emergency ventilator use because it seems very apparent that ResMed has a multitude of firmware versions in production units. If we can figure out how to find the right insertion points in the code for the 0x0 mode feature mask we can automate the process to work on most any arbitrary firmware version.

@nbritton
Copy link
Author

nbritton commented May 1, 2020

I think the very first time I re-flashed the machine it was a bad upload, recall that my IO wire was flakey... the extra menus are working now with just the 0x0 mode feature mask. This code works as is verbatim with my firmware version:

extra_modes() {
        BUILD_FLAGS=$(( BUILD_FLAGS | (1 << 3) ))
        # add more mode entries, set config 0x0 mask to all bits high
        # default is 0x3, which only enables mode 1 (CPAP) and 2 (AutoSet)
        # ---> This is the real magic <---
        printf '\xff\xff' | patch 0x8590 || die failed
}

@dblunk88
Copy link

dblunk88 commented May 1, 2020

Left is 0401 offset, right is the equivalent 0306 offset using a hexdump of both bins. Basically just went through the script and fished out all relevant offsets.
00008590 --> 00008590
00017500 --> 00017500
0001a540 --> 0001a540
0001b860 --> 0001b860
000bb730 --> 000bb4d0
000fd000 is an unwritten offset
000f9c80 --> 000f9a20
0004fa80 --> 0004fa80
00004fc0 --> 00004fc0
00007eb0 --> 00007eb0
00007ee0 --> 00007ee0
00007ec0 --> 00007ec0
000084a0 --> 000084a0
00008590 --> 00008590
00066470 --> 00066470 Note: 0006647c and 0006647d are different values
0006e500 --> 0006e500
0006e4c0 --> 0006e4c0
00004ef0 --> 00004ef0
00017580 --> 00017580
00017760 --> 00017760

As can be seen, there are not a lot of differences. Since the actual firmware is copyrighted, I decided to just post the offsets and not the actual values

@dblunk88
Copy link

dblunk88 commented May 1, 2020

Added a pull request based off of what I found to make patch-airsense compatible

@gszakacs
Copy link

gszakacs commented May 1, 2020

Patched a v306 bin file using dblunk88's update, but I do not see new modes either in the user or the clinical menu.

@dblunk88
Copy link

dblunk88 commented May 1, 2020

@gszakacs comment out patch_code (line 126 if you're using my compatibility patch from my fork https://github.com/dblunk88/airbreak/blob/master/patch-airsense) and uncommenting all_menu (line 131) might help too.

What I think is happening is that you did not compile and it is trying to install the patch_code, which will be missing. Mid-patch it will panic and exit... which leaves you with a half-patched firmware with no modes

Or you could give this a shot and try some of his troubleshooting steps he took in this thread

I think the very first time I re-flashed the machine it was a bad upload, recall that my IO wire was flakey... the extra menus are working now with just the 0x0 mode feature mask. This code works as is verbatim with my firmware version:

extra_modes() {
        BUILD_FLAGS=$(( BUILD_FLAGS | (1 << 3) ))
        # add more mode entries, set config 0x0 mask to all bits high
        # default is 0x3, which only enables mode 1 (CPAP) and 2 (AutoSet)
        # ---> This is the real magic <---
        printf '\xff\xff' | patch 0x8590 || die failed
}

@dblunk88
Copy link

dblunk88 commented May 1, 2020

Also, I will probably attempt to add an automatic hexdump search to find offsets sometime in the future to get all versions compatible (if there are any non-306 and 401 versions floating around). I just don't know how feasible that is due to the need to disclose certain sections in the bin file for the search.

@gszakacs
Copy link

gszakacs commented May 1, 2020

@dblunk88 You are correct. I used the patch file from your repo and run it on my bin,
After following your most recent comments, more items were patched, but I still received a git related fatal error between items 17588 and 17764, Not sure how critical that is.

After patching, I also have the same non-sense menu titles as @nbritton + noticed duplicate "min PS", "max PS", "start EPAP" items in the clinical menu. Some settings are visible but not adjustable, for example the "rise time" "trigger" "cycle". As far as the emergency ventilator functionality those menu items are hopefully irrelevant, but I am curious if you are noticing the same limitations.

@dblunk88
Copy link

dblunk88 commented May 1, 2020

I think the menu items are intentional and may be used as an indicator on what version it is running. You can actually see them being patched in at the end of the script.

As far as the limited options go, I do have the same issue, but really haven't taken the time yet to see on why that is. I'm still getting familiar with the binaries myself... someone else might know the answer though :)

Could you paste the error?

@ruri-baka
Copy link

I've been working on 0302 compatibility and here is what I have so far:

unlock ui limits, extra debug, extra modes, and the gui config address need a +8 offset

comment out extra menu and the second address of all menu, then offset the first (status bit 5) address by +8

The anti-tamper may not be needed but it does need to be offset by +2 to use it.

I haven't tried anything else but that is tested and working on a Rev 1.0 board as well. What I've ran into though is that the GUI areas on 302 are a bit different. For example (from the 0401 stubs file):

NSTUB(0x08066c1b, dispatch_0x38_0x40) is at 664f6 -725
NSTUB(0x080668dd, date_format_time) is at 6589a (I think)

I haven't tested anything else yet but that yields working menus, graphics, and all modes; again on SX567-0302 on a Rev. 1.0 PCB.

@Biorn1950
Copy link

Over 60% of people can not tolerate CPAP

You just invent numbers.
And expiratory effort don't exist due to the fact no muscle intervenes during the exhalation.
About APAP I don't know where you live but in my country it's the doctor who tell to the technician to adjust parameter after the first month of usage. Not the patient.

@Asmageddon
Copy link

Exhalation has a passive phase, and a late active exhalation phase. Furthermore, the airway is not static during exhalation and exhalatory resistance contributes to the process that integrates respiratory effort to culminate in an arousal.
And yeah, that's how it should look, but there's two problems with this- without SD card access, over the air data only gives limited information that is not sufficient for full judgment of how to adjust parameters, and second: it's common for the doctor to just not do this and leave patients on initial settings for months. Refer to the following writeup, also by Krakow: https://www.ncbi.nlm.nih.gov/labs/pmc/articles/PMC6933255/

@exxr
Copy link

exxr commented Sep 3, 2022

@nbritton Basically, I've been trying to flash firmware from one machine(bought a broken ASV) to another, but am finding that it is failing to boot(the airbroken ASV mode does not work correctly)

@Asmageddon Did you ever find out why this didn't work? I believe that the ASV machine has double the on-board RAM of a regular one in order to accommodate the more complex program.

@ArthurMafra
Copy link

ArthurMafra commented Sep 3, 2022

@exxr I faced the bootloop at my first attempt, managed to fix. Are you willing to share ASV firmware? I have ASV working either using airsense firmware or Vauto patched firmware ( working ASV, ASV auto, Autoset, Vauto) . The downside is OSCAR show the settings used, like some modes. I will show graphs and all recorded data correctly. I believe I can manage to have ASV working 100% with you firmware, if you decide to share, I will give it a shot and let you know how it works.

@exxr
Copy link

exxr commented Sep 3, 2022

Sorry @ArthurMafra, I don't have access to the stock ASV firmware, but if it expects more memory won't it fail to run? Although now I'm not so sure if there really is a hardware difference since you claim that the patched firmware works fine in ASV mode, have you done a long term test to ensure it's stable?

@ArthurMafra
Copy link

Hello @exxr . I understood you got broken ASV looking for stock firmware. At first I thought ASV was behaving strangely. After tests, I can say I believe it is working correctly. I got high pressures that increase due to large leaks on masks. ASVauto tries to push air into airways because it was designed for central apneas and the algorithm seams to force air so I should be open or mixed apnea. I can't sleep with cpap maks for more than 1 or 2 hours. I got 5 and 7 one time but it is rare so I gave up. I always I take mask off and just realize next day. What make you believe ASV is not working on yours? I don't think there is any difference on aircurve and airsense models in terms of memory storage. I could not manage to make iVaps work properly. It will require Aircurve ST firmware.

@exxr
Copy link

exxr commented Sep 4, 2022

I was replying to the other commenter who has the broken ASV machine, I don't have one at all at the moment but will be getting an Airsense and will mod it. If you don't mind I'd like to email you for some info?

@Asmageddon
Copy link

Asmageddon commented Sep 4, 2022

@Asmageddon Did you ever find out why this didn't work? I believe that the ASV machine has double the on-board RAM of a regular one in order to accommodate the more complex program.

No, they have the same amount of RAM. 30X ASV firmware worked fine on CPAP that originally had 30X firmware, but not on the 40X one.
The ASV mode unlocked with airbreak seems to work okay too, but does not report the target minute ventilation metric correctly.

It seems that the different firmware have some different config values but the algorithm itself appears to operate fine. Unfortunately, it sometimes goes crazy and starts machine-initiated breathing and doesn't let the body switch back to natural, which makes it pretty disruptive for sleep.

@exxr
Copy link

exxr commented Sep 4, 2022

It seems that the different firmware have some different config values but the algorithm itself appears to operate fine. Unfortunately, it sometimes goes crazy and starts machine-initiated breathing and doesn't let the body switch back to natural, which makes it pretty disruptive for sleep.

Is this only an issue with the patched firmware? Or are you talking about the different firmware versions 30x vs 40x? If so, besides the reporting issue does the patched firmware function 100% correctly?

@ruri-baka
Copy link

Did y’all pay attention to board versions and the differences between them? 1.0 doesn’t have the auxiliary connections that are used on the ASV model to connect to the battery backed alarm board used on the ASV model; the 1.1 board does. It may very well be that some board versions can support ASV and some can’t; if it’s a 1.0 board that was never designed with a thought towards ASV that board could’ve been made in sub-variants with different chips that have varying amounts of RAM…later on they would’ve standardized the 1.1 variant if they were actually utilizing the extra RAM.

@Asmageddon
Copy link

Asmageddon commented Sep 5, 2022

@exxr 30x ASV works on 30x CPAP hardware, 40x firmware doesn't. Likewise, 30x firmware doesn't work on the 40x model.

@ruri-baka Thanks for the clarification. I'm not an electronics/reverse-engineering person, and I forgot to actually consider that. If you're well-versed in it, I'd love to contact you as I'm trying to figure out how to knockdown the backup rate feature in ASV mode, but very far out of my specialty here.

@ArthurMafra
Copy link

My airsense came with 306BR. 401 US firmware works on my 30x6 hardware. Including myair app. Aircuve VAuto 302 firmware works on 306 Airsense hardware. Aircurve firmware on airsense will cause myair to deregister the device after first use due to serial /model differences, register again, work one time and keep deregistering.
I believe the ASV backup rate is not an option that users can adjust. It may show as an option if "show all menus" are enabled during patch but it is not a parameter that exists on stock ASV firmware according ASV Clinician guide, they have default 15 that adjust automatically during breathing analysis.
During my test, modes that require extra parameters that only show when allmenu is enabled, will not operate correctly, for example ST mode and Ivaps. They don't seem reliable because the machine ignores forced changed values.  I did extensive post on apneaboard with help of the friendly people there that believed the ASV was not acting correctly, but I found people with Aircurve ASV stock experienced same problems, including one user that was breathing deeper and caused ASV misbehave, so it seems that It is most how ASV operate not airbreak patch itself. 
I simply can't wear masks, maybe the smallest ones. Looking at my graphs, I took the mask at high pressure, I took it at low pressure, stock firmware, patched firmware no matter the mode, the pressure. So it is a problem with mask adaptation and I tried resmed quattro, F20, F&P evora full (better to sleep). Did not try the nasal because I mouth breath. I'm going to check 401 patched firmware to recall the problems I faced and let you know.

@Asmageddon
Copy link

@ArthurMafra I might have seen that post, as I've done similar research to confirm that yeah, stock ASV goes apesh*t with the backup rate too. If possible I'd like to reverse engineer the feature off, since I believe it compromises therapy efficacy.

The truth is that PAP is really poor at managing Sleep Disordered Breathing. It seems to mostly help people who developed it with age, whose nasal breathing isn't awful and airway size okay.

You could try a nasal mask(most people can adapt to it at least a bit), nasal dilators, or a soft cervical collar(prevents chin tucking that worsens apnea), but long term you should look into either nasal surgery(don't recommend), or the more effective surgically assisted palatal expansion(MSE/EASE/SAMSE/SAMARPE/etc.), which enlarges your entire nasal cavity. Possibly, you might need MMA surgery too, since receded jaws are what causes airway collapsibility.

If you'd like, add me on Discord(9246#eomamalL backwards), we've got a community and lists of providers.

@ttkirst
Copy link

ttkirst commented Nov 23, 2022

Here are the results https://docs.google.com/spreadsheets/d/1_i6PF-nABOaD_m5coIUW_zA4tfrCzPFv0MkYMmZaUq8/edit?usp=sharing

If anyone has 302 and 401, please let me know. I'll add your results to the file

@dblunk88 Please can you assist me. I have 0302 firmware on Airsense 10 CPAP. My firmware hash is: dac92172863440cef65643166a8c3e4b22e4c3e15da2f9f20f463e831d316473

I patched the patch using @ruri-baka 's patch but when trying to patch the firmware I get the incorrect hash error. Is it safe to just include my hash in the patch? I saw you wrote a script to compare offsets but since I only have my firmware, it is not of much use. Do you have any idea how I can proceed? Thanks for all your hard work. I really appreciate it.

Kind regards,
Tyler

--EDIT

I managed to flash the "patched" firmware by replacing the hash in the patch with my stm32.bin hash. On testing it seems not all the functions are working properly (NB: Not all were tested.). Namely:
CPAP - Seems to work as it did before, with addition of the bar graph showing pressure. Only thing I noticed is it may not be relieving pressure as well as it did when exhaling.
AUTOSET - Shows pressure bar graph as with cpap but min and max both stay at 4cmH2O no matter what I try.
APAP - Exactly the same as autoset.
iVAPS - Seems to work, only displays bar graph of varying pressure. Seems to work similar to what one would expect a ventilator to do. Pulses higher pressure until air enters the lungs. If you breath the pressure is reduced.

Didn't try other modes as I'm not sure what to expect from them. Line graph of pressure did not seem to appear anywhere. I also noticed that the pressure unit in the settings menu was "USE" instead of cmH2O as before. I have since restored the original firmware until I figure it out.

@Asmageddon
Copy link

I'm not sure if the scripts for 030X work, and it sounds like you probably corrupted your image. Good call to just restore it. Feel free to add me on Discord I might be able to help you.

@Asmageddon
Copy link

@nbritton If you know the answer, could you take a look at #55 ?

@ttkirst
Copy link

ttkirst commented Dec 8, 2022

Thanks, What is your discord username?

@Asmageddon
Copy link

9246#eomamalL backwards.

@megaduo
Copy link

megaduo commented Apr 15, 2023

9246#eomamalL backwards.
Hi,i have same issue,the hash not match,my hash is 98b01cc34b42f999b3c5295340efe61f1b7b41aff6cac5825b6772f6fc73b274.Can i add your on discord, i can not find user eomamalL#9246 anymore.

@jcorde
Copy link

jcorde commented Jul 4, 2023

I had the same issue, although I am using 0401. My hash is 85eb07896a9b843417d0b670b01b5534bd9e7097e947f0d7eeab8d4990e5d73a.

I was able to have it working by modifying the patch-airsense and using the following:

# unlock_ui_limits
# extra_debug
extra_modes
extra_menu
# all_menu
gui_config

(I also had to change the expected hash).

@alex-woodhouse
Copy link

@Asmageddon I'd love to discuss disabling backup rate in more detail. I've added you on discord if you're up for it 😊

@scowell
Copy link

scowell commented Feb 3, 2024

I just want bi-level features from my AS10.

I'm working with a newer C2C machine that claims to be sx567-0401... but the checksum does not match supposed 0401. I used Bash to generate a true checksum on my FW and got patch-airsense to run (commenting out the extra breath stuff). I did a diff and find that spurious things noted here like FLAGS= instead of My Options, GIT= instead of Sleep (Report)... so I dont' trust it. Evidently it's being caused by this:

FLAGSTR=$(printf 'FLAGS=0x%02x' $BUILD_FLAGS)
printf $FLAGSTR | patch 0x17588

COMMIT_HASH=$(git log -n1 --format=format:"%H" | head -c 7)
printf 'GIT=%s\x00' $COMMIT_HASH | patch 0x17764

Gonna try it again and comment out the printf patches. I'll post back here. I also commented out the HACKED stuff.

Here's my 0401 C2C stock checksum hash:

a8d740fce5840d48078c71b39c2682d63d61466b3d6a10dfda3c37111ced8844

Looks like they're jiggering it to mess with us! Why not just turn on the Security bit? Crazy that it's open anyway... my little widgets never leave the plant open like that.

@scowell
Copy link

scowell commented Feb 3, 2024

Holy crap, it worked! I definitely don't recommend doing this to your main machine... have a spare around... or two! I have an S9, an AS10 from 2015, and this AS10 C2C I bought Nov 2023 'black Friday' for $399 new. I had to edit the script as described above... I flashed the new unit, since I'm experimenting with updating the modem (put a new motor cleaned etc) on the old unit... even put an external antenna on it, four bars of 4G with ATT... now to just jigger MyAir the right way, it has not worked so far... delete and start new account?

Anyway, the proof's in the sleeping, I'll put this one back in rotation on normal APAP and see if it hiccups. I've scheduled a new sleep study (been 14 years) and I'm thinking bi-level will help with my UARS and EFL's. Can't wait to see my doctor's face when I bring this into him to have program... he's already pissed I'm using Oscar and getting great results.

Thanks to all the previous hacktastic hackers working on this. I stand on the shoulders of giants.

@scowell
Copy link

scowell commented Feb 3, 2024

I've noticed if I don't have 'all options all the time' menu enabled it's missing some stuff from some modes... and when it's enabled all the menus are confusing. More work necessary here. Let's see if it kills me tonight.

@Asmageddon
Copy link

@scowell Would you add me on Discord? I'd love to chat with you, I've done a lot more work with implementing custom algorithms too.

@scowell
Copy link

scowell commented Feb 5, 2024

@scowell Would you add me on Discord? I'd love to chat with you, I've done a lot more work with implementing custom algorithms too.

Am I on Discord? My interest here is more into maintenance rather than creating a ventilator... I want to access the EEPROM to do things like reset the motor hours and change the modem ID so that older AutoSets can be updated with 4G modems. I haven't even got the disassembly going yet... much less the C-code. I'm hacking my way through the patch-airsense script... I'm not a Linuxian, having to remember bash etc and figger stuff out in context. IOW, I'm a real newb at this. Lurking around I've gotten my hands on a lot of RM FW, going to try sleeping with a bi-level tonight... running Beyond Compare on these bins has been instructive. Turns out there's four or five 0401 firmwares available, some with more diffs than others. I would like to change parms on scoring RERAs, etc.

I was able to sleep a full night on APAP with my jailbreak code... so it didn't kill me, that's a success in my book... the Oscar of it did show a suspicious 25cm max pressure limit... hee hee. Now it's replaced with vAuto stock FW and working nicely... going to have a problem with Oscar data if I can't access the EEPROM (or wherever it is) and change the SD card file headers to reflect the data on the card... it's not in the FW for the STM32.

I do envision that these AS10 carcasses will become the open-source PAP platform for the future... eternally grateful that the security bit was not set (all my widgets leave the plant locked, of course). Is RM giving us tacet approval? Or are they just completely clueless? All my bootloaders are encrypt-capable... nothing goes out en-clair. I've watched some video of the CEO... he's a real piece of work, climate-change denier etc. Love his machines.

Does anyone have a clue what this:

FLAGSTR=$(printf 'FLAGS=0x%02x' $BUILD_FLAGS)
printf $FLAGSTR | patch 0x17588

is about? It just seems to screw up the menu display.

@scowell
Copy link

scowell commented Feb 5, 2024

@scowell Would you add me on Discord? I'd love to chat with you, I've done a lot more work with implementing custom algorithms too.

I am on Discord! And I sent you a friend req.

@scowell
Copy link

scowell commented Feb 7, 2024

@scowell Would you add me on Discord? I'd love to chat with you, I've done a lot more work with implementing custom algorithms too.

... and you didn't accept. Does this happen often here? Am I just a sucker?

@Asmageddon
Copy link

@scowell omg I'm sorry. I don't remember rejecting a friend request but I've had some really bad two weeks. Send again? I'm now just eomamalL backwards with no extra numbers.

And yeah that bit of script replaces one of the strings, it's debug info for the jailbreak so to speak.

@johnie89
Copy link

@scowell Would you add me on Discord? I'd love to chat with you, I've done a lot more work with implementing custom algorithms too.

I am on Discord! And I sent you a friend req.

Could you add me too? I'm johnie89 on discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests