From owner-freebsd-arm@FreeBSD.ORG Sun May 4 11:42:42 2014 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08A31FE2 for ; Sun, 4 May 2014 11:42:42 +0000 (UTC) Received: from orange.myspectrum.nl (orange.myspectrum.nl [149.210.134.247]) by mx1.freebsd.org (Postfix) with ESMTP id BCF591BC9 for ; Sun, 4 May 2014 11:42:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by orange.myspectrum.nl (Postfix) with ESMTP id 50EDC8ADF1; Sun, 4 May 2014 13:33:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at myspectrum.nl Received: from orange.myspectrum.nl ([127.0.0.1]) by localhost (orange.myspectrum.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W2SQSOsQiC06; Sun, 4 May 2014 13:33:32 +0200 (CEST) Received: from [192.168.0.7] (ip136-5-208-87.adsl2.static.versatel.nl [87.208.5.136]) (Authenticated sender: dasuboot@myspectrum.nl) by orange.myspectrum.nl (Postfix) with ESMTPSA id 586658ADEE; Sun, 4 May 2014 13:33:32 +0200 (CEST) Message-ID: <1399203211.1994.25.camel@yellow> Subject: Re: [U-Boot] Latest u-boot release on BeagleBone Black for FreeBSD From: Jeroen Hofstee To: Xuebing Wang Date: Sun, 04 May 2014 13:33:31 +0200 In-Reply-To: <5343B8B9.6040607@gmail.com> References: <5343B8B9.6040607@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: trini@ti.com, u-boot@lists.denx.de, vanbaren@cideas.com, freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 May 2014 11:42:42 -0000 Hello Xuebing, (freebsd-arm added on cc), On di, 2014-04-08 at 16:52 +0800, Xuebing Wang wrote: > Hi u-boot community, > > I am trying to port u-boot (release u-boot-2014.04-rc3.tar.bz2) to > FreeBSD on BeagleBone Black. > > In FreeBSD, there is a u-boot loader (named ubldr), which can call > u-boot API to get fdt (Flat Device Tree) data. > > I have to comment out below 3 lines, in order to get correct fdt data in > FreeBSD ubldr from u-boot. Would you please advice what is the best way > to fix this? > > In file common/env_common.c: > const uchar *env_get_addr(int index) > { > // if (gd->env_valid) > // return (uchar *)(gd->env_addr + index); > // else > return &default_environment[index]; > } > Assuming that you checked that your environment is valid you might be facing the fact that the gd pointer is corrupted. gd is a pointer to the "global data" and used for storing globals which are available before and after relocation. On (32bit) ARM this value used to be stored in register r8 but moved to r9 (llvm cannot reserve an arbitrary register, but can reserve r9 for platform specific usage). If ubldr uses r9 you end up with a invalid gd pointer when calling back into u-boot. ubldr now reserves r8 and r9 so a recent version should work fine on an older U-boot as well as current master. Can you check the latest ubldr? Regards, Jeroen