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

Bypassing the "Use the official adapter" screen #17

Open
fonix232 opened this issue Nov 6, 2022 · 1 comment
Open

Bypassing the "Use the official adapter" screen #17

fonix232 opened this issue Nov 6, 2022 · 1 comment

Comments

@fonix232
Copy link

fonix232 commented Nov 6, 2022

This is not really an issue, as I've already solved it, but rather a guide that could be worthwhile to add to the repo.

If you're not using the official adapter and cable supplied with the Car Thing, you'll most likely run into the boot error message instructing you to use the official power adapter.

This is of course bollocks, because this thing can easily run off of any power adapter that can supply the appropriate amount of amps at 5V. 1A seems to be more than enough as I was able to get past this screen via my dumb power strip's USB port.

But, it is an annoyance, and it isn't that simple to get past it, unless your Google-fu is top notch (hint: it's done by pressing the small front button, and Button 5 on top, holding the two together until the alert goes away).

There is, however, a permanent way to get rid of this, by editing the bootcmd environment variable.

This var by default is set to run check_charger, which in turn runs the check_charger env var's content, the following string of commands:

mw 0xFF6346DC 0x33000000;mw.b 0x1337DEAD 0x00 1;mw.b 0x1330DEAD 0x12 1;mw.b 0x1331DEAD 0x13 1;mw.b 0x1332DEAD 0x15 1;mw.b 0x1333DEAD 0x16 1;i2c dev 2;i2c read 0x35 0x3 1 0x1337DEAD;if cmp.b 0x1337DEAD 0x1330DEAD 1; then run storeboot;elif cmp.b 0x1337DEAD 0x1331DEAD 1; then run storeboot;elif cmp.b 0x1337DEAD 0x1332DEAD 1; then run storeboot;elif cmp.b 0x1337DEAD 0x1333DEAD 1; then run storeboot;else osd open;osd clear;imgread pic logo bad_charger $loadaddr;bmp display $bad_charger_offset;bmp scale;vout output ${outputmode};while true; do sleep 1; if gpio input GPIOAO_3; then run splash_boot; fi; i2c read 0x35 0x3 1 0x1337DEAD;if cmp.b 0x1337DEAD 0x1330DEAD 1; then run splash_boot;elif cmp.b 0x1337DEAD 0x1331DEAD 1; then run splash_boot;elif cmp.b 0x1337DEAD 0x1332DEAD 1; then run splash_boot;elif cmp.b 0x1337DEAD 0x1333DEAD 1; then run splash_boot;fi;i2c mw 0x35 0x09 0x8F 1;done;fi;

Here it is, a bit formatted:

mw 0xFF6346DC 0x33000000;
mw.b 0x1337DEAD 0x00 1;
mw.b 0x1330DEAD 0x12 1;
mw.b 0x1331DEAD 0x13 1;
mw.b 0x1332DEAD 0x15 1;
mw.b 0x1333DEAD 0x16 1;
i2c dev 2;
i2c read 0x35 0x3 1 0x1337DEAD;
if cmp.b 0x1337DEAD 0x1330DEAD 1; 
	then run storeboot;
elif cmp.b 0x1337DEAD 0x1331DEAD 1; 
	then run storeboot;
elif cmp.b 0x1337DEAD 0x1332DEAD 1; 
	then run storeboot;
elif cmp.b 0x1337DEAD 0x1333DEAD 1; 
	then run storeboot;
else osd open;
	osd clear;
	imgread pic logo bad_charger $loadaddr;
	bmp display $bad_charger_offset;
	bmp scale;
	vout output ${outputmode};
	while true; 
		do sleep 1; 
	if gpio input GPIOAO_3; 
		then run splash_boot; 
	fi; 
	i2c read 0x35 0x3 1 0x1337DEAD;
	if cmp.b 0x1337DEAD 0x1330DEAD 1; 
		then run splash_boot;
	elif cmp.b 0x1337DEAD 0x1331DEAD 1; 
		then run splash_boot;
	elif cmp.b 0x1337DEAD 0x1332DEAD 1; 
		then run splash_boot;
	elif cmp.b 0x1337DEAD 0x1333DEAD 1; 
		then run splash_boot;
	fi;
	i2c mw 0x35 0x09 0x8F 1;
	done;
fi;

Now I'm not claiming that I fully understand the above script, but what I broke it down to (and please correct me if I'm wrong) is basically:

  1. Store a few predefined values in the indicated 0x1337DEAD, 0x1330DEAD - 0x1333DEAD addresses
  2. Read from I2C device 2 at address 0x35 0x3, into the memory address 0x1337DEAD (I presume writing 0x00 on line 2 simply resets that memory address)
  3. Compare the read value with the predefined values set in step 1.
  4. If the read value matches any of the predefined values (0x12, 0x13, 0x15 or 0x16), go to step 9
  5. If the read value does not match, display the bad_charger bitmap, and continue
  6. Refresh every second/millisecond (sleep 1 - not sure if in U-boot env this means 1s or 1ms)
  7. If GPIOAO_3 (button 4) is pressed, go to step 9
  8. Read and compare values again
    a. I presume the i2c mw ..... command resets the I2C device in question to get a new (power?) reading
  9. run splash_boot - continue booting the system.

This check can be easily bypassed simply by setting the bootcmd env var to run splash_boot instead of check_charger:

./bin/update bulkcmd 'amlmmc env'
./bin/update bulkcmd 'setenv bootcmd run splash_boot'
./bin/update bulkcmd 'env save'

After sending these commands, the Car Thing should now completely bypass all power adapter checks.

@npjohnson
Copy link
Collaborator

Thanks, I may integrate this by default

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

2 participants