If a man has two wives, one of them loved and the other disliked, and if both the loved and the disliked have borne him sons, the firstborn being the son of the one who is disliked,
then on the day when he wills his possessions to his sons, he is not permitted to treat the son of the loved as the firstborn in preference to the son of the disliked, who is the firstborn.
He must acknowledge as firstborn the son of the one who is disliked, giving him a double portion of all that he has; since he is the first issue of his virility, the right of the firstborn is his.
References for Deuteronomy 21:17
If someone has a stubborn and rebellious son who will not obey his father and mother, who does not heed them when they discipline him,
then his father and his mother shall take hold of him and bring him out to the elders of his town at the gate of that place.
They shall say to the elders of his town, "This son of ours is stubborn and rebellious. He will not obey us. He is a glutton and a drunkard."
Then all the men of the town shall stone him to death. So you shall purge the evil from your midst; and all Israel will hear, and be afraid.
When someone is convicted of a crime punishable by death and is executed, and you hang him on a tree,
his corpse must not remain all night upon the tree; you shall bury him that same day, for anyone hung on a tree is under God's curse. You must not defile the land that the Lord your God is giving you for possession.