[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] troubles with Petalinux and libgen in XPS 11.1



Hi folks,

On Thu, May 28, 2009 at 7:25 AM, Nicolas Herve <nicolas.herve@xxxxxxxxx> wrote:
> I test XPS 11.1 with petalinux following the same procedure than on
> the tutorial and when I run libgen
> (do "Generate  Libraries and Drivers") I got some trouble.
> Is there some incompatibility issue and have to stick with XPS 10.1 for now ?

For those ready to start using 11.1, attached is a patch that applies
to the petalinux BSP tools, which works around the TCL bugs / API
changes introduced in 11.1.  Apply at patchlevel -p0 from the top of
your petalinux tree.

I've build-tested kernels+u-boot for HW projects under EDK10.1 and
11.1, and it all looks fine at this end.

So, 11.1 adopters please try it out, and anyone using 10.1 please also
give it a try, make sure it doesn't break anything for you.  Same goes
for 9.1 users.

Once I get some feedback I'll apply it to SVN.

Thanks,

John
-- 
John Williams, PhD, B.Eng, B.IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
Index: hardware/edk_user_repository/PetaLogix/bsp/petalinux_v1_00_b/data/petalinux_v2_1_0.tcl
===================================================================
--- hardware/edk_user_repository/PetaLogix/bsp/petalinux_v1_00_b/data/petalinux_v2_1_0.tcl	(revision 5104)
+++ hardware/edk_user_repository/PetaLogix/bsp/petalinux_v1_00_b/data/petalinux_v2_1_0.tcl	(working copy)
@@ -19,7 +19,6 @@
 # Known limitations:
 
 
-
 # Globals
 # config_file and hdr_file hold file handles for the
 # auto-config.in and auto-config.h files respectively.
@@ -41,10 +40,13 @@
 
 # Create a namespace that incorporates the standalone BSP functionality
 proc create_standalone_namespace {} {
+    global standalone_ver
+	set standalone_ver "v2_00_a"
+
     namespace eval standalone_bsp {
         global env
         set edk_path $env(XILINX_EDK)
-        source ${edk_path}/sw/lib/bsp/standalone_v1_00_a/data/standalone_v2_1_0.tcl
+        source ${edk_path}/sw/lib/bsp/standalone_${standalone_ver}/data/standalone_v2_1_0.tcl
     }
 } 
 
@@ -82,6 +84,7 @@
     global config_file hdr_file kconfig_file
     global edk_path
     global env
+    global standalone_ver
 
     set edk_path $env(XILINX_EDK)
     create_standalone_namespace
@@ -144,9 +147,9 @@
     # Point into Xilinx EDK to get standalone BSP files, so we don't
     # need to duplicate them here
 
-    set orig_mbsrcdir "${edk_path}/sw/lib/bsp/standalone_v1_00_a/src/microblaze"
-    set orig_ppcsrcdir "${edk_path}/sw/lib/bsp/standalone_v1_00_a/src/ppc405"
-    set orig_profilesrcdir "${edk_path}/sw/lib/bsp/standalone_v1_00_a/src/profile"
+    set orig_mbsrcdir "${edk_path}/sw/lib/bsp/standalone_${standalone_ver}/src/microblaze"
+    set orig_ppcsrcdir "${edk_path}/sw/lib/bsp/standalone_${standalone_ver}/src/ppc405"
+    set orig_profilesrcdir "${edk_path}/sw/lib/bsp/standalone_${standalone_ver}/src/profile"
     set mbsrcdir "./src/microblaze"
     set ppcsrcdir "./src/ppc405"
     set profilesrcdir "./src/profile"
@@ -404,6 +407,15 @@
     }
 
     generate_params $proc_string $args    
+
+    # FIXME special handling of HW_VER for the CPU
+    # EDK11.1 broke this in the TCL, so we have to do it manually
+    # see Xilinx AR#32529
+    catch {
+        set procver [xget_value $hwproc_handle "PARAMETER" "HW_VER"];
+        generate_string_param XILINX_${proc_string}_HW_VER $procver "CPU Version";
+    }
+
     generate_generic "" 
 }
 
@@ -475,6 +487,9 @@
 			# Get parent periphs of sink port for IRQ signal
 			set sink_periph [xget_hw_parent_handle $sink_port]
 			set handletype [xget_value $sink_periph "handletype"]
+			if [string match "" $handletype] {
+				set handletype IPINST
+			}
 			# Only get instance type for IPINSTances
 			if {![string match -nocase IPINST $handletype]} {
 				incr sink_idx;
@@ -548,8 +563,14 @@
 		# interface adapters
 		
 		# Get instance name for current peripheral
-		set inst_handle [xget_hw_parameter_handle $periph "INSTANCE"]
-		set instance_name [string toupper [xget_value $inst_handle]]
+                # see Xilinx AR#32529 for why this is necessary
+		# Try the new way first
+		if {[catch {set instance_name [xget_hw_name $periph]}]} {
+			# That failed, use the old
+			set inst_handle [xget_hw_parameter_handle $periph "INSTANCE"]
+			set instance_name [string toupper [xget_value $inst_handle]]
+		}
+
 		# Has this instance been overridden?
 		if {![string match [array names override_array $instance_name] "" ]} {
 			set periph_name $override_array($instance_name)
@@ -575,6 +596,14 @@
 		set periph_string [format "%s_%s" $periph_name $device_id]
 		if {[string compare -nocase "MPMC" $periph_name]} {
 			generate_params $periph_string $args
+                        # FIXME special handling of HW_VER and INSTANCE parameters
+                        # EDK11.1 broke this in the TCL, so we have to do it manually
+                        # see Xilinx AR#32529
+			catch {
+                        	set core_ver [xget_value $periph "PARAMETER" "HW_VER"];
+				generate_string_param XILINX_${periph_string}_HW_VER $core_ver "Core version number"
+				generate_string_param XILINX_${periph_string}_INSTANCE $instance_name "Core instance name"
+			}
 		}
 
 		# Special handling for MDM core, but not sure why
@@ -999,7 +1028,7 @@
 	set param_value [xget_value $h_param "VALUE"]
 
 	# format according to datatype
-	set dt [string toupper [xget_hw_subproperty_value $h_param "DT"]]
+	set dt [guess_param_dt $h_param]
 
 	switch -regexp $dt {
 		INTEGER {
@@ -1044,7 +1073,7 @@
 	set param_value [xget_value $param "VALUE"]
 
 	# format according to datatype
-	set dt [string toupper [xget_hw_subproperty_value $param "DT"]]
+	set dt [guess_param_dt $param]
 
 	switch -regexp $dt {
 		INTEGER {
@@ -1087,7 +1116,8 @@
 		}
 		
 		# Get the datatype of the parameter
-		set dt [string toupper [xget_hw_subproperty_value $h_param "DT"]]
+		set dt [guess_param_dt $h_param]
+
 		# Get a description of the parameter
 		set descr [xget_hw_subproperty_value $h_param "DESC"]
 		set name [xget_value $h_param "NAME"]
@@ -1242,3 +1272,45 @@
     puts $hdr_file "${text_string}"
 }
 
+# Attempt to guess the EDK DT (datatype) for given parameter h_param
+# This is because 11.1 broke the handling of subproperty "DT"
+# see Xilinx AR#32529
+proc guess_param_dt {h_param} {
+	set param_dt [string toupper [xget_hw_subproperty_value $h_param "DT"]]
+	set param_value [xget_value $h_param "VALUE"]
+
+	switch -regexp $param_dt {
+		"" {
+			# it's empty, probably because we are using broken 11.1
+			# tcl release.  Try to figure out the datatype as
+			# best we can
+			
+			# Strip any underscores, as they are valid in MHS/MPD
+			# syntax as group seperators for hex and binary values
+			set new_param_value [string map {_ ""} $param_value]
+			
+			set val_as_int ""
+			catch {set val_as_int [format "%i" ${new_param_value}]}
+			if [ string match ${new_param_value} ${val_as_int} ] {
+				return "INTEGER"
+			}
+
+			# Hex values start with 0x
+			if {[string match -nocase 0x* $param_value]} {
+				return "STD_LOGIC_VECTOR"
+			}
+			# Binary values start with 0b
+			if {[string match -nocase 0b* $param_value]} {
+				return "STD_LOGIC_VECTOR"
+			}
+
+			# Can't figure it out, so just give up and call it a string
+			return "STRING"
+
+		}
+		default {
+			# Do nothing
+		}
+	}
+	return $param_dt
+}