Bug 195525

Summary: Carambola2 (or any ar71xx devices) don't parse uboot arguments and environment variables
Product: Base System Reporter: bugs
Component: kernAssignee: Bugmeister <bugmeister>
Status: Closed Overcome By Events    
Severity: Affects Some People    
Priority: ---    
Version: 10.1-RELEASE   
Hardware: mips   
OS: Any   

Description bugs 2014-11-30 12:28:33 UTC
I have a carambola2 which I build FreeBSD using freebsd-wifi-build.
The kernel fails to read the uboot environment, producing the following errors:

    argv is invalid
    envp is invalid

I tracked this down to sys/mips/.atheros/ar71xx_machdep.c and the following code fragment:

	/*
	 * Until some more sensible abstractions for uboot/redboot
	 * environment handling, we have to make this a compile-time
	 * hack.  The existing code handles the uboot environment
	 * very incorrectly so we should just ignore initialising
	 * the relevant pointers.
	 */
#ifndef	AR71XX_ENV_UBOOT
	argc = a0;
	argv = (char**)a1;
	envp = (char**)a2;


For the Carambola2, those registers are in fact accurate and should not be #ifdef'd out.  However, the variables are in fact an array of strings of "name=value" not pairs of strings "name", "value", so to fix this for my own case I had to extend the code that parses them later in the file.

Notwithstanding the comment regards 'more sensible abstractions', I have a patch that makes the variables work (for the carambola2, at least)

https://github.com/pastcompute/freebsd/commit/9d06660cb53ff4c07048aaab0b086e612f5f155f

However, I suspect you may wish to restrict this fix to _just_ the carambola2 board, lest it break other peoples systems.  Any advice on how to filter a fragment of code to a specific kernel configuration would be appreciated, as I am mostly experienced with hacking other systems kernels...
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2025-01-25 01:02:25 UTC
^Triage: I'm sorry that this PR did not get addressed in a timely fashion.

By now, the version that it was created against is long out of support.
Please re-open if it is still a problem on a supported version.